blob: 3f06cf8630a48c16759da24fa3c5701cdea90e9a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnsonc63b4a22017-09-19 08:30:14 -07002 * Copyright (c) 2014-2015, 2017 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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_pal_packet.c
31
32 \brief Implementation for PAL packet. wpt = (Wlan Pal Type) wpal = (Wlan PAL)
33
34 Definitions for platform with VOSS packet support and LA.
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036
37 ========================================================================*/
38
39#include "wlan_qct_pal_packet.h"
40#include "wlan_qct_pal_api.h"
41#include "wlan_qct_pal_trace.h"
Mihir Shete058fcff2014-06-26 18:54:06 +053042#include "wlan_qct_os_status.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "vos_packet.h"
44#include "vos_trace.h"
45#include "vos_list.h"
Mihir Shete2187b8c2015-03-18 16:54:29 +053046#include "vos_api.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48#include <linux/skbuff.h>
49#include "dma-mapping.h"
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +053050#include <linux/wcnss_wlan.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070051
52/*Per spec definition*/
53#define WPAL_ETHERNET_PAKCET_HEADER_SIZE 14
54
55/*Per spec definition - not including QOS field*/
56#define WPAL_802_11_PACKET_HEADER_SIZE 24
57
58/*p is a pointer to wpt_packet*/
59#define WPAL_TO_VOS_PKT(p) ((vos_pkt_t *)(p))
60
61
62typedef struct
63{
64 void* pPhyAddr;
65 wpt_uint32 uLen;
66}wpt_iterator_info;
67
68/* Storage for DXE CB function pointer */
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070069static wpalPacketLowPacketCB wpalPacketAvailableCB;
Jeff Johnson295189b2012-06-20 16:38:30 -070070
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070071/* Temp storage for transport channel DIAG/LOG information
72 * Each channel will update information with different context
73 * Before send stored date to DIAG,
74 * temporary it should be stored */
75static wpt_log_data_stall_type wpalTrasportStallInfo;
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070076
Jeff Johnson295189b2012-06-20 16:38:30 -070077/*
78 wpalPacketInit is no-op for VOSS-support wpt_packet
79*/
80wpt_status wpalPacketInit(void *pPalContext)
81{
82 return eWLAN_PAL_STATUS_SUCCESS;
83}
84
85
86/*
87 wpalPacketClose is no-op for VOSS-support wpt_packet
88*/
89wpt_status wpalPacketClose(void *pPalContext)
90{
91 return eWLAN_PAL_STATUS_SUCCESS;
92}
93
94/*---------------------------------------------------------------------------
95 wpalPacketRXLowResourceCB – RX RAW packer CB function
96 Param:
97 pPacket – Available RX packet
98 userData - PAL Client Context, DXE
99 Return:
100 Status
101---------------------------------------------------------------------------*/
102VOS_STATUS wpalPacketRXLowResourceCB(vos_pkt_t *pPacket, v_VOID_t *userData)
103{
104 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
105 void* pData = NULL;
106
107 if (NULL == pPacket)
108 {
109 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
110 "Get new RX PAL packet fail");
111 return VOS_STATUS_E_FAILURE;
112 }
113 vosStatus = vos_pkt_reserve_head_fast( pPacket, &pData,
114 VPKT_SIZE_BUFFER );
115 if(VOS_STATUS_SUCCESS != vosStatus)
116 {
117 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
118 "Prepare RX packet for DXE fail");
119 return VOS_STATUS_E_FAILURE;
120 }
121
122 if((NULL == wpalPacketAvailableCB) || (NULL == userData))
123 {
124 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
125 "Invalid ARG for new RX packet");
126 return VOS_STATUS_E_FAILURE;
127 }
128
129 wpalPacketAvailableCB( (wpt_packet *)pPacket, userData );
Madan Mohan Koyyalamudic2994452013-08-16 11:27:23 +0530130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 return VOS_STATUS_SUCCESS;
132}
133
134/*---------------------------------------------------------------------------
135 wpalPacketAlloc – Allocate a wpt_packet from PAL.
136 Param:
137 pktType – specify the type of wpt_packet to allocate
138 nPktSize - packet size
139 Return:
140 A pointer to the wpt_packet. NULL means fail.
141---------------------------------------------------------------------------*/
142wpt_packet * wpalPacketAlloc(wpt_packet_type pktType, wpt_uint32 nPktSize,
143 wpalPacketLowPacketCB rxLowCB, void *usrData)
144{
145 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
146 wpt_packet* pPkt = NULL;
147 vos_pkt_t* pVosPkt = NULL;
148 void* pData = NULL;
Leo Changb419a912013-03-29 18:58:21 -0700149 v_U16_t allocLen;
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
151
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 switch (pktType)
153 {
154 case eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT:
155 vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_TX_802_11_MGMT,
156 nPktSize, 1, VOS_FALSE,
157 NULL, NULL /*no callback*/);
158 break;
159
160 case eWLAN_PAL_PKT_TYPE_RX_RAW:
Mihir Sheteb20fd742013-12-31 12:41:35 +0530161 /* Set the wpalPacketAvailableCB before we try to get a VOS
162 * packet from the 'free list' and reset it if vos_pkt_get_packet()
163 * returns a valid packet. This order is required to avoid the
164 * race condition:
165 * 1. The below call to vos_pkt_get_packet() in RX_Thread determines
166 * that no more packets are available in the 'free list' and sets
167 * the low resource callbacks.
168 * 2. in parallel vos_pkt_return_packet() is called in MC_Thread for a
169 * Management frame before wpalPacketAlloc() gets a chance to set
170 * wpalPacketAvailableCB and since the 'low resource callbacks'
171 * are set the callback function - wpalPacketRXLowResourceCB is
172 * executed,but since wpalPacketAvailableCB is still NULL the low
173 * resource recovery fails.
174 */
175 wpalPacketAvailableCB = rxLowCB;
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_RX_RAW,
178 nPktSize, 1, VOS_FALSE,
179 wpalPacketRXLowResourceCB, usrData);
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 /* Reserve the entire raw rx buffer for DXE */
182 if( vosStatus == VOS_STATUS_SUCCESS )
183 {
Mihir Sheteb20fd742013-12-31 12:41:35 +0530184 wpalPacketAvailableCB = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 vosStatus = vos_pkt_reserve_head_fast( pVosPkt, &pData, nPktSize );
186 }
Mihir Shetebc338242015-03-04 15:34:19 +0530187
Leo Chang59232a82013-05-07 14:25:35 -0700188 if((NULL != pVosPkt) && (VOS_STATUS_E_RESOURCES != vosStatus))
Leo Changb419a912013-03-29 18:58:21 -0700189 {
Leo Chang59232a82013-05-07 14:25:35 -0700190 vos_pkt_get_packet_length(pVosPkt, &allocLen);
191 if (nPktSize != allocLen)
192 {
193 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
194 "RX packet alloc has problem, discard this frame, Len %d", allocLen);
195 vos_pkt_return_packet(pVosPkt);
196 return NULL;
197 }
Leo Changb419a912013-03-29 18:58:21 -0700198 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 break;
200
201 default:
202 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800203 " try to allocate unsupported packet type (%d)", pktType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 break;
205 }
206
207 if(VOS_IS_STATUS_SUCCESS(vosStatus))
208 {
209 pPkt = (wpt_packet *)pVosPkt;
210 }
211
212
213 return pPkt;
214}/*wpalPacketAlloc*/
215
216
217
218/*---------------------------------------------------------------------------
219 wpalPacketFree – Free a wpt_packet chain for one particular type.
220 For our legacy UMAC, it is not needed because vos_packet contains pal_packet.
221 Param:
222 pPkt – pointer to a wpt_packet
223 Return:
224 eWLAN_PAL_STATUS_SUCCESS - success
225---------------------------------------------------------------------------*/
226wpt_status wpalPacketFree(wpt_packet *pPkt)
227{
228 VOS_STATUS vosStatus;
229
230 if(NULL != pPkt->pInternalData)
231 {
232 wpalMemoryFree(pPkt->pInternalData);
233 }
234 vosStatus = vos_pkt_return_packet(WPAL_TO_VOS_PKT(pPkt));
235
236 //With VOSS support, we can cast between wpt_status and VOS_STATUS
237 return (wpt_status)vosStatus;
238}/*wpalPacketFree*/
239
240
241/*---------------------------------------------------------------------------
242 wpalPacketGetLength – Get number of bytes in a wpt_packet. It include the
243 bytes in a BD if it exist.
244 Param:
245 pPkt - pointer to a packet to be freed.
246 Return:
247 Length of the data include layer-2 headers. For example, if the frame
248 is 802.3, the length includes the ethernet header.
249---------------------------------------------------------------------------*/
250wpt_uint32 wpalPacketGetLength(wpt_packet *pPkt)
251{
252 v_U16_t len = 0, pktLen = 0;
253
254 // Validate the parameter pointers
255 if (unlikely(NULL == pPkt))
256 {
257 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700258 "%s : NULL packet pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 return eWLAN_PAL_STATUS_E_INVAL;
260 }
261
262
263 if( WPAL_PACKET_GET_BD_POINTER(pPkt) )
264 {
265 len = WPAL_PACKET_GET_BD_LENGTH(pPkt);
266 }
267 if( VOS_IS_STATUS_SUCCESS(vos_pkt_get_packet_length(WPAL_TO_VOS_PKT(pPkt), &pktLen)) )
268 {
269 len += pktLen;
270 }
271 else
272 {
Arif Hussain9a5d5382013-11-17 22:05:35 -0800273 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, "%s failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700274 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 }
276
277 return ((wpt_uint32)len);
278}/*wpalPacketGetLength*/
279
280
281/*---------------------------------------------------------------------------
282 wpalPacketRawTrimHead – Move the starting offset and return the head pointer
283 before the moving. The function can only be used with raw packets,
284 whose buffer is one piece and allocated by WLAN driver. This also
285 reduce the length of the packet.
286 Param:
287 pPkt - pointer to a wpt_packet.
288 size – number of bytes to take off the head.
289 Return:
290 A pointer to the original buffer head before the trimming.
291---------------------------------------------------------------------------*/
292wpt_status wpalPacketRawTrimHead(wpt_packet *pPkt, wpt_uint32 size)
293{
294 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
295
296 // Validate the parameter pointers
297 if (unlikely(NULL == pPkt))
298 {
299 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700300 "%s : NULL packet pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 return eWLAN_PAL_STATUS_E_INVAL;
302 }
303
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800304 if ((eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT == WPAL_PACKET_GET_TYPE(pPkt)) ||
305 (eWLAN_PAL_PKT_TYPE_RX_RAW == WPAL_PACKET_GET_TYPE(pPkt)))
306 {
307 // Continue to trim the packet
308 }
309 else
310 {
311 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
312 "%s : neither 80211 managment packet nor RAW packet", __func__);
313 VOS_ASSERT(0);
314 return eWLAN_PAL_STATUS_E_INVAL;
315 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700316
317 if( !VOS_IS_STATUS_SUCCESS(vos_pkt_trim_head(WPAL_TO_VOS_PKT(pPkt), (v_SIZE_t)size)) )
318 {
Arif Hussain9a5d5382013-11-17 22:05:35 -0800319 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, "%s Invalid trim(%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700320 __func__, size);
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 status = eWLAN_PAL_STATUS_E_INVAL;
322 }
323
324 return status;
325}/*wpalPacketRawTrimHead*/
326
327/*---------------------------------------------------------------------------
328 wpalPacketRawTrimTail – reduce the length of the packet.
329 Param:
330 pPkt - pointer to a wpt_packet.
331 size – number of bytes to take of the packet length
332 Return:
333 eWLAN_PAL_STATUS_SUCCESS – success. Otherwise fail.
334---------------------------------------------------------------------------*/
335wpt_status wpalPacketRawTrimTail(wpt_packet *pPkt, wpt_uint32 size)
336{
337 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
338
339 // Validate the parameter pointers
340 if (unlikely(NULL == pPkt))
341 {
342 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700343 "%s : NULL packet pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 return eWLAN_PAL_STATUS_E_INVAL;
345 }
346
Manjunathappa Prakashfb585462013-12-23 19:07:07 -0800347 if ((eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT == WPAL_PACKET_GET_TYPE(pPkt)) ||
348 (eWLAN_PAL_PKT_TYPE_RX_RAW == WPAL_PACKET_GET_TYPE(pPkt)))
349 {
350 // Continue to trim the packet
351 }
352 else
353 {
354 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
355 "%s : neither 80211 managment packet nor RAW packet", __func__);
356 VOS_ASSERT(0);
357 return eWLAN_PAL_STATUS_E_INVAL;
358 }
359
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 if( !VOS_IS_STATUS_SUCCESS(vos_pkt_trim_tail(WPAL_TO_VOS_PKT(pPkt), (v_SIZE_t)size)) )
361 {
Arif Hussain9a5d5382013-11-17 22:05:35 -0800362 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, "%s Invalid trim(%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700363 __func__, size);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 status = eWLAN_PAL_STATUS_E_INVAL;
365 }
366
367 return status;
368}/*wpalPacketRawTrimTail*/
369
370
371/*---------------------------------------------------------------------------
372 wpalPacketGetRawBuf – Return the starting buffer virtual address for the RAW flat buffer
373 It is inline in hope of faster implementation for certain platform. For Winxp, it
374 will be slow.
375 Param:
376 pPkt - pointer to a wpt_packet.
377 Return:
378 NULL - fail.
379 Otherwise the address of the starting of the buffer
380---------------------------------------------------------------------------*/
381wpt_uint8 *wpalPacketGetRawBuf(wpt_packet *pPkt)
382{
383 wpt_uint8 *pRet = NULL;
384
385 // Validate the parameter pointers
386 if (unlikely(NULL == pPkt))
387 {
388 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700389 "%s : NULL packet pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 return NULL;
391 }
392
393 //Since it is a flat buffer, all we need is to get one byte of offset 0
394 if( (eWLAN_PAL_PKT_TYPE_RX_RAW == WPAL_PACKET_GET_TYPE(pPkt)) ||
395 (eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT == WPAL_PACKET_GET_TYPE(pPkt)) )
396 {
397 vos_pkt_peek_data(WPAL_TO_VOS_PKT(pPkt), 0, (v_VOID_t**)&pRet, 1);
398 WPAL_ASSERT(NULL != pRet);
399 }
400
401 return pRet;
402}/*wpalPacketGetRawBuf*/
403
404
405/*---------------------------------------------------------------------------
406 wpalPacketSetRxLength – Set the valid data length on a RX packet. This function must
407 be called once per RX packet per receiving. It indicates the available data length from
408 the start of the buffer.
409 Param:
410 pPkt - pointer to a wpt_packet.
411 Return:
412 NULL - fail.
413 Otherwise the address of the starting of the buffer
414---------------------------------------------------------------------------*/
415wpt_status wpalPacketSetRxLength(wpt_packet *pPkt, wpt_uint32 len)
416{
417 // Validate the parameter pointers
418 if (unlikely(NULL == pPkt))
419 {
420 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700421 "%s : NULL packet pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 return eWLAN_PAL_STATUS_E_INVAL;
423 }
424
425 /*Only allowed for RX Raw packets */
426 if( (eWLAN_PAL_PKT_TYPE_RX_RAW != WPAL_PACKET_GET_TYPE(pPkt)))
427 {
428 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800429 "%s Invalid packet type(%d)", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 WPAL_PACKET_GET_TYPE(pPkt));
431 return eWLAN_PAL_STATUS_E_INVAL;
432 }
433
434 if(VOS_IS_STATUS_SUCCESS(vos_pkt_set_rx_length(WPAL_TO_VOS_PKT(pPkt), len)))
435 {
436 return eWLAN_PAL_STATUS_SUCCESS;
437 }
438 else
439 {
440 return eWLAN_PAL_STATUS_E_INVAL;
441 }
442}/*wpalPacketSetRxLength*/
443
Bhargav Shah7dbfb6f2016-02-12 20:49:58 +0530444void wpalRecoverTail(wpt_packet *pFrame)
445{
446 // Validate the parameter pointers
447 if (unlikely(NULL == pFrame))
448 {
449 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
450 "%s : NULL packet pointer", __func__);
451 return;
452 }
453
454 return vos_recover_tail(WPAL_TO_VOS_PKT(pFrame));
455}
456
457void* wpalGetOSPktHead(wpt_packet *pFrame)
458{
459 // Validate the parameter pointers
460 if (unlikely(NULL == pFrame))
461 {
462 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
463 "%s : NULL packet pointer", __func__);
464 return NULL;
465 }
466
467 return vos_get_pkt_head(WPAL_TO_VOS_PKT(pFrame));
468}
469
470void* wpalGetOSPktend(wpt_packet *pFrame)
471{
472 // Validate the parameter pointers
473 if (unlikely(NULL == pFrame))
474 {
475 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
476 "%s : NULL packet pointer", __func__);
477 return 0;
478 }
479
480 return vos_get_pkt_end(WPAL_TO_VOS_PKT(pFrame));
481}
482
Jeff Johnson295189b2012-06-20 16:38:30 -0700483/*
484 Set of helper functions that will prepare packet for DMA transfer,
485 based on the type of transfer : - to and from the device
486 - following these calls the packet will be locked for DMA only,
487 CPU will not be able to modify it => the packet must be explicitly returned to
488 the CPU once the DMA transfer is complete
489*/
490WPT_STATIC WPT_INLINE void* itGetOSPktAddrForDevice( wpt_packet *pPacket )
491{
492 struct sk_buff *skb;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530493 struct device *wcnss_device = (struct device *)gContext.devHandle;
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530495
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 if ( VOS_STATUS_SUCCESS !=
497 vos_pkt_get_os_packet(WPAL_TO_VOS_PKT(pPacket), (void**)&skb, VOS_FALSE ))
498 {
499 return NULL;
500 }
501 else
502 {
503 /*Map skb data into dma-able memory
504 (changes will be commited from cache) */
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530505 return (void*)dma_map_single( wcnss_device, skb->data, skb->len, DMA_TO_DEVICE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 }
507}/*itGetOSPktAddrForDevice*/
508
509WPT_STATIC WPT_INLINE void* itGetOSPktAddrFromDevice( wpt_packet *pPacket )
510{
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 struct sk_buff *skb;
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530512 struct device *wcnss_device = (struct device *)gContext.devHandle;
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530514
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 if ( VOS_STATUS_SUCCESS !=
516 vos_pkt_get_os_packet(WPAL_TO_VOS_PKT(pPacket), (void**)&skb, VOS_FALSE ))
517 {
518 return NULL;
519 }
520 else
521 {
Arun Kumar Khandavalli1d0647d2014-03-26 18:16:15 +0530522 if((uintptr_t)skb->data == (uintptr_t)skb->tail)
Mihir Shete5929ea52014-02-18 00:10:36 +0530523 {
524#ifdef WLAN_BUG_ON_SKB_ERROR
525 wpalDevicePanic();
526#else
527 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_FATAL,
528 "%s: skb->data == skb->tail. Attempting recovery "
Jeff Johnsonc63b4a22017-09-19 08:30:14 -0700529 "skb:%pK, head:%pK, tail:%pK, data:%pK",
Mihir Shete5929ea52014-02-18 00:10:36 +0530530 __func__, skb, skb->head, skb->tail, skb->data);
531
532 skb->data = skb->head;
533#endif
534 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 /*Map skb data into dma-able memory
536 (changes will be commited from cache) */
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530537 return (void*)dma_map_single( wcnss_device, skb->data, skb->len, DMA_FROM_DEVICE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 }
539}/*itGetOSPktAddrFromDevice*/
540
541/*
542 Set of helper functions that will return a DMA-ed packet to the CPU,
543 based on the type of transfer : - to and from the device
544*/
545WPT_STATIC WPT_INLINE void itReturnOSPktAddrForDevice( wpt_packet *pPacket, void* addr, wpt_uint32 size )
546{
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530547 struct device *wcnss_device = (struct device *)gContext.devHandle;
548
549 dma_unmap_single( wcnss_device, (dma_addr_t)addr, size, DMA_TO_DEVICE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700550}
551
552WPT_STATIC WPT_INLINE void itReturnOSPktAddrFromDevice( wpt_packet *pPacket, void* addr, wpt_uint32 size )
553{
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530554 struct device *wcnss_device = (struct device *)gContext.devHandle;
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530556 dma_unmap_single( wcnss_device, (dma_addr_t)addr, size, DMA_FROM_DEVICE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700557}
558
559
560/*---------------------------------------------------------------------------
561 wpalIteratorInit – Initialize an interator by updating pCur to first item.
562 Param:
563 pIter – pointer to a caller allocated wpt_iterator
564 pPacket – pointer to a wpt_packet
565 Return:
566 eWLAN_PAL_STATUS_SUCCESS - success
567---------------------------------------------------------------------------*/
568wpt_status wpalIteratorInit(wpt_iterator *pIter, wpt_packet *pPacket)
569{
570 wpt_status status = eWLAN_PAL_STATUS_SUCCESS;
571 wpt_iterator_info* pCurInfo = NULL;
572 wpt_iterator_info* pNextInfo = NULL;
573 wpt_iterator_info* pPktInfo = NULL;
574
575 // Validate the parameter pointers
576 if (unlikely((NULL == pPacket)||(NULL==pIter)))
577 {
578 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Jeff Johnsonc63b4a22017-09-19 08:30:14 -0700579 "%s : NULL input pointers %pK %pK", __func__, pPacket, pIter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 return eWLAN_PAL_STATUS_E_INVAL;
581 }
582
583 pPktInfo = (wpt_iterator_info*)pPacket->pInternalData;
584 if (unlikely(NULL == pPktInfo))
585 {
586 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700587 "%s : Invalid Packet Info", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return eWLAN_PAL_STATUS_E_INVAL;
589 }
590
591 // if there is NO BD on this frame, then initialize the next pointer to
592 // point the first fragment.
593 if ( NULL == WPAL_PACKET_GET_BD_PHYS(pPacket) )
594 {
595 pCurInfo = pPktInfo;
596 pNextInfo = NULL;
597 }
598 else
599 {
600 /*Allocate memory for the current info*/
601 pCurInfo = wpalMemoryAllocate( sizeof(wpt_iterator_info) );
602
603 // Validate the memory allocation
604 if (unlikely(NULL == pCurInfo))
605 {
606 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700607 "%s : Failed to allocate memory ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 return eWLAN_PAL_STATUS_E_INVAL;
609 }
610
611 pCurInfo->pPhyAddr = WPAL_PACKET_GET_BD_PHYS(pPacket);
612 pCurInfo->uLen = WPAL_PACKET_GET_BD_LENGTH(pPacket);
613
614 pNextInfo = pPktInfo;
615 }
616
617 pIter->pCur = (void*)pCurInfo;
618 pIter->pNext = (void*)pNextInfo;
619 pIter->pContext = NULL;
620
621 return status;
622}/*wpalIteratorInit*/
623
624/*---------------------------------------------------------------------------
625 wpalIteratorNext – Get the address for the next item
626 Param:
627 pIter – pointer to a caller allocated wpt_iterator
628 pPacket – pointer to a wpt_packet
629 ppAddr – Caller allocated pointer to return the address of the item.
630 For DMA-able devices, this is the physical address of the item.
631 pLen – To return the number of bytes in the item.
632 Return:
633 eWLAN_PAL_STATUS_SUCCESS - success
634---------------------------------------------------------------------------*/
635wpt_status wpalIteratorNext(wpt_iterator *pIter, wpt_packet *pPacket, void **ppAddr, wpt_uint32 *pLen)
636{
637 wpt_iterator_info* pCurInfo = NULL;
638 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
639
640 /*-------------------------------------------------------------------------
641 Sanity check
642 -------------------------------------------------------------------------*/
643 if (unlikely(( NULL == pIter )||( NULL == pPacket ) ||
644 ( NULL == ppAddr ) || ( NULL == pLen )))
645 {
646 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800647 "%s Invalid input parameters", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -0700648 return eWLAN_PAL_STATUS_E_INVAL;
649 }
650
651 pCurInfo = (wpt_iterator_info*)pIter->pCur;
652 /*-------------------------------------------------------------------------
653 If current pointer is NULL - there is no data in the packet - return
654 -------------------------------------------------------------------------*/
655 if( pIter->pCur == NULL )
656 {
657 *ppAddr = NULL;
658 *pLen = 0;
659 return eWLAN_PAL_STATUS_SUCCESS;
660 }
661
662 /*Address and length are kept in the current field*/
663 *ppAddr = pCurInfo->pPhyAddr;
664 *pLen = pCurInfo->uLen;
665
666 if( NULL == pIter->pNext )
667 {
668 /*Save the iterator for cleanup*/
669 pPacket->pInternalData = pIter->pCur;
670 pIter->pCur = NULL;
671 }
672 else
673 {
674 /*Release the memory saved for storing the BD information*/
675 wpalMemoryFree(pCurInfo);
676
677 /*For LA - the packet is represented by maximum 2 fields of data
678 - BD and actual data from sk buff */
679 pIter->pCur = pIter->pNext;
680 pIter->pNext = NULL;
681 }
682
683 return eWLAN_PAL_STATUS_SUCCESS;
684}
685
686/*---------------------------------------------------------------------------
687 wpalLockPacketForTransfer – Map the data buffer from dma so that the
688 data is commited from cache and the cpu relinquishes
689 ownership of the buffer
690
691 Param:
692 pPacket – pointer to a wpt_packet
693
694 Return:
695 eWLAN_PAL_STATUS_SUCCESS - success
696---------------------------------------------------------------------------*/
697wpt_status wpalLockPacketForTransfer( wpt_packet *pPacket)
698{
699 void* pPhyData = NULL;
700 wpt_iterator_info* pInfo = NULL;
701 v_U16_t uLenData = 0;
702
703 // Validate the parameter pointers
704 if (unlikely(NULL == pPacket))
705 {
706 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700707 "%s : NULL input pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 return eWLAN_PAL_STATUS_E_INVAL;
709 }
710
711 switch(WPAL_PACKET_GET_TYPE(pPacket))
712 {
713 /* For management frames, BD is allocated by WDI, header is in raw buffer,
714 rest of the frame is also in raw buffer */
715 case eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT:
716 {
717 /*TX Packets need to be DMA-ed to the device, perform DMA mapping
718 accordingly */
719 pPhyData = (void*)itGetOSPktAddrForDevice( pPacket );
720 }
721 break;
722 /* Data packets - BD (allocated by WDI), header (in VOSS header),
723 rest of the packet (DSM items) */
724 case eWLAN_PAL_PKT_TYPE_TX_802_11_DATA:
725 case eWLAN_PAL_PKT_TYPE_TX_802_3_DATA:
726 {
727 /*TX Packets need to be DMA-ed to the device, perform DMA mapping
728 accordingly */
729 pPhyData = (void*)itGetOSPktAddrForDevice( pPacket );
730 }
731 break;
732
733 /* For Raw RX, BD + header + rest of the packet is all contained in the raw
734 buffer */
735 case eWLAN_PAL_PKT_TYPE_RX_RAW:
736 {
737 /*RX Packets need to be DMA-ed from the device, perform DMA mapping
738 accordingly */
739 pPhyData = (void*)itGetOSPktAddrFromDevice( pPacket );
740 }
741 break;
742
743 default:
744 {
745 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700746 " WLAN_PAL: %s: Invalid packet type %d!", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 WPAL_PACKET_GET_TYPE(pPacket) );
748 WPAL_ASSERT(0);
749 return eWLAN_PAL_STATUS_E_FAILURE;
750 }
751 }
752
753 /*Get packet length*/
754 vos_pkt_get_packet_length(WPAL_TO_VOS_PKT(pPacket),&uLenData);
755
756 /*Allocate memory for the current info*/
757 pInfo = wpalMemoryAllocate( sizeof(wpt_iterator_info) );
758
759 // Validate the memory allocation
760 if (unlikely(NULL == pInfo))
761 {
762 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700763 "%s : Failed to allocate memory ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 return eWLAN_PAL_STATUS_E_INVAL;
765 }
766
767 pInfo->pPhyAddr = pPhyData;
768 pInfo->uLen = uLenData;
769
770 pPacket->pInternalData = pInfo;
771 return eWLAN_PAL_STATUS_SUCCESS;
772}/*wpalLockPacketForTransfer*/
773
774/*---------------------------------------------------------------------------
775 wpalUnlockPacket – Unmap the data buffer from dma so that cpu can regain
776 ownership on it
777 Param:
778 pPacket – pointer to a wpt_packet
779
780 Return:
781 eWLAN_PAL_STATUS_SUCCESS - success
782---------------------------------------------------------------------------*/
783wpt_status wpalUnlockPacket( wpt_packet *pPacket)
784{
785
786 wpt_iterator_info* pInfo;
787
788 // Validate the parameter pointers
789 if (unlikely(NULL == pPacket))
790 {
791 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700792 "%s : NULL input pointer pPacket", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 return eWLAN_PAL_STATUS_E_INVAL;
794 }
795
796 pInfo = (wpt_iterator_info*)pPacket->pInternalData;
797
798 // Validate pInfo
799 if (unlikely(NULL == pInfo))
800 {
801 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700802 "%s : NULL input pointer pInfo", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 return eWLAN_PAL_STATUS_E_INVAL;
804 }
805
806 switch(WPAL_PACKET_GET_TYPE(pPacket))
807 {
808 /* For management frames, BD is allocated by WDI, header is in raw buffer,
809 rest of the frame is also in raw buffer */
810 case eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT:
811 {
812 /*TX Packets need to be DMA-ed to the device, perform DMA mapping
813 accordingly */
814 itReturnOSPktAddrForDevice(pPacket, pInfo->pPhyAddr, pInfo->uLen);
815 }
816 break;
817 /* Data packets - BD (allocated by WDI), header (in VOSS header),
818 rest of the packet (DSM items) */
819 case eWLAN_PAL_PKT_TYPE_TX_802_11_DATA:
820 case eWLAN_PAL_PKT_TYPE_TX_802_3_DATA:
821 {
822 /*TX Packets need to be DMA-ed to the device, perform DMA mapping
823 accordingly */
824 itReturnOSPktAddrForDevice(pPacket, pInfo->pPhyAddr, pInfo->uLen);
825 }
826 break;
827
828 /* For Raw RX, BD + header + rest of the packet is all contained in the raw
829 buffer */
830 case eWLAN_PAL_PKT_TYPE_RX_RAW:
831 {
832 /*RX Packets need to be DMA-ed from the device, perform DMA mapping
833 accordingly */
Madan Mohan Koyyalamudif850f1c2012-12-05 16:03:53 -0800834 if(NULL == pInfo->pPhyAddr)
835 {
836 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
837 " WLAN_PAL: %s: RX frame was not locked properly", __func__);
838 }
839 else
840 {
841 itReturnOSPktAddrFromDevice(pPacket, pInfo->pPhyAddr, pInfo->uLen);
842 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 }
844 break;
845
846 default:
847 {
848 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700849 " WLAN_PAL: %s: Invalid packet type %d!", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 WPAL_PACKET_GET_TYPE(pPacket) );
851 WPAL_ASSERT(0);
852 return eWLAN_PAL_STATUS_E_FAILURE;
853 }
854 }
855
856 wpalMemoryFree(pInfo);
857 pPacket->pInternalData = NULL;
858 return eWLAN_PAL_STATUS_SUCCESS;
859}/*wpalUnlockPacket*/
860
861/*---------------------------------------------------------------------------
862 wpalIsPacketLocked – Check whether the Packet is locked for DMA.
863 Param:
864 pPacket – pointer to a wpt_packet
865
866 Return:
867 eWLAN_PAL_STATUS_SUCCESS
868 eWLAN_PAL_STATUS_E_FAILURE
869 eWLAN_PAL_STATUS_E_INVAL
870---------------------------------------------------------------------------*/
871wpt_status wpalIsPacketLocked( wpt_packet *pPacket)
872{
873
874 wpt_iterator_info* pInfo;
875
876 /* Validate the parameter pointers */
877 if (NULL == pPacket)
878 {
Gopichand Nakkala0dfe0a92013-06-19 21:50:26 +0530879 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_WARN,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700880 "%s : NULL input pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 return eWLAN_PAL_STATUS_E_INVAL;
882 }
883
884 /* Validate pInternalData */
885 pInfo = (wpt_iterator_info*)pPacket->pInternalData;
886 return (NULL == pInfo)? eWLAN_PAL_STATUS_E_FAILURE :
887 eWLAN_PAL_STATUS_SUCCESS;
888}/*wpalIsPacketLocked*/
889
Gopichand Nakkalaa2cb10c2013-05-03 17:48:29 -0700890/*---------------------------------------------------------------------------
891 wpalGetNumRxRawPacket Query available RX RAW total buffer count
892 param:
893 numRxResource pointer of queried value
894
895 return:
896 eWLAN_PAL_STATUS_SUCCESS
897---------------------------------------------------------------------------*/
898wpt_status wpalGetNumRxRawPacket(wpt_uint32 *numRxResource)
899{
900 *numRxResource = (wpt_uint32)vos_pkt_get_num_of_rx_raw_pkts();
901
902 return eWLAN_PAL_STATUS_SUCCESS;
903}
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700904
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700905/*---------------------------------------------------------------------------
Mihir Sheted183cef2014-09-26 19:17:56 +0530906 wpalGetNumRxPacketAllocFailures Get number of times packet alloc failed
907 numRxResource pointer of queried value
908
909 return:
910 eWLAN_PAL_STATUS_SUCCESS
911---------------------------------------------------------------------------*/
912wpt_status wpalGetNumRxPacketAllocFailures(wpt_uint32 *numRxResource)
913{
914 *numRxResource = (wpt_uint32)vos_pkt_get_num_of_rx_pkt_alloc_failures();
915
916 return eWLAN_PAL_STATUS_SUCCESS;
917}
918/*---------------------------------------------------------------------------
Mihir Shete058fcff2014-06-26 18:54:06 +0530919 wpalGetNumRxFreePacket Query available RX Free buffer count
920 param:
921 numRxResource pointer of queried value
922
923 return:
924 WPT_STATUS
925---------------------------------------------------------------------------*/
926wpt_status wpalGetNumRxFreePacket(wpt_uint32 *numRxResource)
927{
928 VOS_STATUS status;
929
930 status = vos_pkt_get_available_buffer_pool(VOS_PKT_TYPE_RX_RAW,
931 (v_SIZE_t *)numRxResource);
932
933 return WPAL_VOS_TO_WPAL_STATUS(status);
934}
935
936/*---------------------------------------------------------------------------
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700937 wpalPacketStallUpdateInfo – Update each channel information when stall
938 detected, also power state and free resource count
939
940 Param:
941 powerState ? WLAN system power state when stall detected
942 numFreeBd ? Number of free resource count in HW
943 channelInfo ? Each channel specific information when stall happen
944 channelNum ? Channel number update information
945
946 Return:
947 NONE
948
949---------------------------------------------------------------------------*/
950void wpalPacketStallUpdateInfo
951(
952 v_U32_t *powerState,
953 v_U32_t *numFreeBd,
954 wpt_log_data_stall_channel_type *channelInfo,
955 v_U8_t channelNum
956)
957{
958 /* Update power state when stall detected */
959 if(NULL != powerState)
960 {
961 wpalTrasportStallInfo.PowerState = *powerState;
962 }
963
964 /* Update HW free resource count */
965 if(NULL != numFreeBd)
966 {
967 wpalTrasportStallInfo.numFreeBd = *numFreeBd;
968 }
969
970 /* Update channel information */
971 if(NULL != channelInfo)
972 {
973 wpalMemoryCopy(&wpalTrasportStallInfo.dxeChannelInfo[channelNum],
974 channelInfo,
975 sizeof(wpt_log_data_stall_channel_type));
976 }
977
978 return;
979}
980
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +0530981#ifdef FEATURE_WLAN_DIAG_SUPPORT
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700982/*---------------------------------------------------------------------------
983 wpalPacketStallDumpLog – Trigger to send log packet to DIAG
984 Updated transport system information will be sent to DIAG
985
986 Param:
987 NONE
988
989 Return:
990 NONE
991
992---------------------------------------------------------------------------*/
993void wpalPacketStallDumpLog
994(
995 void
996)
997{
998 vos_log_data_stall_type *log_ptr = NULL;
999
1000 WLAN_VOS_DIAG_LOG_ALLOC(log_ptr, vos_log_data_stall_type, LOG_TRSP_DATA_STALL_C);
1001 if(log_ptr)
1002 {
1003 log_ptr->PowerState = wpalTrasportStallInfo.PowerState;
1004 log_ptr->numFreeBd = wpalTrasportStallInfo.numFreeBd;
1005 wpalMemoryCopy(&log_ptr->dxeChannelInfo[0],
1006 &wpalTrasportStallInfo.dxeChannelInfo[0],
1007 WPT_NUM_TRPT_CHANNEL * sizeof(vos_log_data_stall_channel_type));
1008 pr_info("Stall log dump");
1009 WLAN_VOS_DIAG_LOG_REPORT(log_ptr);
1010 }
1011
1012 return;
1013}
1014#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Mihir Shete2187b8c2015-03-18 16:54:29 +05301015
1016/*---------------------------------------------------------------------------
1017 wpalLogPktSerialize - Serialize Logging data to logger thread
1018
1019 Param:
1020 wpt_packet pFrame - The packet which contains the logging data.
1021 This packet has to be a VALID packet, as this
1022 API will not do any checks on the validity of
1023 the packet.
1024
1025 Return:
1026 NONE
1027
1028---------------------------------------------------------------------------*/
1029void wpalLogPktSerialize
1030(
1031 wpt_packet *pFrame
1032)
1033{
1034 WDI_DS_RxMetaInfoType *pRxMetadata;
1035 void *pBuffer;
1036 VOS_STATUS vosStatus;
1037
1038 vosStatus = vos_pkt_peek_data(WPAL_TO_VOS_PKT(pFrame), 0, &pBuffer,
1039 WDI_DS_LOG_PKT_TYPE_LEN);
1040
1041 if (VOS_IS_STATUS_SUCCESS(vosStatus))
1042 {
1043 // a VALID packet implies non NULL meta-data
1044 pRxMetadata = WDI_DS_ExtractRxMetaData(pFrame);
Mihir Sheteccafc0c2015-04-17 16:13:15 +05301045 pRxMetadata->loggingData = *((wpt_uint32 *)pBuffer);
1046
1047 wpalPacketRawTrimHead(pFrame, WDI_DS_LOG_PKT_TYPE_LEN);
1048
Mihir Shete2187b8c2015-03-18 16:54:29 +05301049 vos_logger_pkt_serialize(WPAL_TO_VOS_PKT(pFrame), pRxMetadata->loggingData);
1050 }
1051 else
1052 {
1053 vos_pkt_return_packet(WPAL_TO_VOS_PKT(pFrame));
1054 }
1055}
Mihir Shete5affadc2015-05-29 20:54:57 +05301056
1057/*---------------------------------------------------------------------------
1058 wpalFwLogPktSerialize - Serialize Logging data to logger thread
1059
1060 Param:
1061 wpt_packet pFrame - The packet which contains the logging data.
1062 This packet has to be a VALID packet, as this
1063 API will not do any checks on the validity of
1064 the packet.
1065
1066 Return:
1067 NONE
1068
1069---------------------------------------------------------------------------*/
1070void wpalFwLogPktSerialize
1071(
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +05301072 wpt_packet *pFrame, wpt_uint32 pktType
Mihir Shete5affadc2015-05-29 20:54:57 +05301073)
1074{
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +05301075 vos_logger_pkt_serialize(WPAL_TO_VOS_PKT(pFrame), pktType);
Mihir Shete5affadc2015-05-29 20:54:57 +05301076}
Sushant Kaushik33200572015-08-05 16:46:20 +05301077
1078
1079/*---------------------------------------------------------------------------
1080 wpalPerPktSerialize - Serialize perpkt data to logger thread
1081
1082 Param:
1083
1084
1085 Return:
1086 NONE
1087
1088---------------------------------------------------------------------------*/
1089void wpalPerPktSerialize
1090(
1091 void *perPktStat
1092)
1093{
1094 vos_per_pkt_stats_to_user(perPktStat);
1095}