blob: e57fda9d6a60026821b7c641960553bf8a5bb4cf [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#if !defined( __WLAN_QCT_PAL_PACKET_H )
29#define __WLAN_QCT_PAL_PACKET_H
30
31/**=========================================================================
32
33 \file wlan_qct_pal_packet.h
34
35 \brief define PAL packet. wpt = (Wlan Pal Type)
36
37 Definitions for platform independent.
38
Jeff Johnson295189b2012-06-20 16:38:30 -070039 ========================================================================*/
40
41#include "wlan_qct_pal_type.h"
42#include "wlan_qct_pal_status.h"
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +053043#include "vos_types.h"
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070044#ifdef FEATURE_WLAN_DIAG_SUPPORT
45#include "vos_diag_core_log.h"
46#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48// The size of the data buffer in vos/pal packets
49// Explanation:
50// MTU size = 1500 bytes
51// Max number of BD/PDUs required to hold payload of 1500 =
52// 12 PDUs (124 bytes each) + 1 BD (12 bytes for payload) =
53// 13 BD/PDUs = 13 x 128 = 1664 bytes
54//
55// In case of A-MSDU with each MSDU having payload of 1500 bytes:
56// 1st MSDU = requires 13 BD/PDUs as per the above equation.
57// 2nd MSDU = HW inserts an extra BD to hold the information of the 2nd
58// MSDU and the payload portion of this BD is unused which means to cover
59// 1500 bytes we require 13 PDUs.
60// So 13 PDUs + 1 BD = 14 BD/PDUs = 1792 bytes.
61//
62// HOWEVER
63// In case of A-MSDU with errors, the ADU will push to the host up to
64// 2346 bytes. If that is the 2nd or later MSDU the worst case is:
65// 1 Prepended BD/PDU
66// 1 BD/PDU containing the 1st 4 bytes of the delimiter
67// 1 BD/PDU containing the last 10 bytes of the delimiter
68// plus the first 114 of the payload
69// 18 BD/PDUs containing the remaining 2232 bytes of the payload
70// 2346 - 114 = 2232; 2232 / 124 = 18
71// So 21 BD/PDUs are required
Jeff Johnsone7245742012-09-05 17:12:55 -070072
73//The size of AMSDU frame per spec can be a max of 3839 bytes
74// in BD/PDUs that means 30 (one BD = 128 bytes)
75// we must add the size of the 802.11 header to that
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -080076#define VPKT_SIZE_BUFFER ((30 * 128) + 32)
Jeff Johnson295189b2012-06-20 16:38:30 -070077
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070078/* Transport channel count to report DIAG */
Mihir Shetef26cacd2015-06-08 08:02:00 +053079#define WPT_NUM_TRPT_CHANNEL 8
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070080/* Transport channel name string size */
81#define WPT_TRPT_CHANNEL_NAME 4
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -070082
Jeff Johnson295189b2012-06-20 16:38:30 -070083typedef enum
84{
85 ///Packet is used to transmit 802.11 Management frames.
86 eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT,
87 ///Packet is used to transmit 802.11 Data frames.
88 eWLAN_PAL_PKT_TYPE_TX_802_11_DATA,
89 ///Packet is used to transmit 802.3 Data frames.
90 eWLAN_PAL_PKT_TYPE_TX_802_3_DATA,
91 ///Packet contains Received data of an unknown frame type
92 eWLAN_PAL_PKT_TYPE_RX_RAW
93} wpt_packet_type;
94
95
96typedef struct swpt_packet
97{
98 /*
99 Pointer to a buffer for BD for TX packets
100 For RX packets. The pBD MUST set to NULL.
101 PAL packet shall set the pointer point to the start of the flat buffer
102 where the BD starts.
103 */
104 void *pBD;
105 //Physical address for pBD for DMA-able devices
106 void *pBDPhys;
107 //OS dependent strucutre used only by OS specific code.
108 void *pOSStruct;
109 void *pktMetaInfo;
110 wpt_packet_type pktType;
111 //The number of bytes pBD uses. It MUST be set to 0 for RX packets
112 wpt_uint16 BDLength;
113
114 //Internal data for PAL packet implementation usage only
115 void *pInternalData;
116} wpt_packet;
117
118typedef struct swpt_iterator
119{
120 void *pNext;
121 void *pCur;
122 void *pContext;
123} wpt_iterator;
124
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700125/* Each specific channel dedicated information should be logged */
126typedef struct
127{
128 char channelName[WPT_TRPT_CHANNEL_NAME];
129 v_U32_t numDesc;
130 v_U32_t numFreeDesc;
131 v_U32_t numRsvdDesc;
132 v_U32_t headDescOrder;
133 v_U32_t tailDescOrder;
134 v_U32_t ctrlRegVal;
135 v_U32_t statRegVal;
136 v_U32_t numValDesc;
137 v_U32_t numInvalDesc;
138} wpt_log_data_stall_channel_type;
139
140/* Transport log context */
141typedef struct
142{
143 v_U32_t PowerState;
144 v_U32_t numFreeBd;
145 wpt_log_data_stall_channel_type dxeChannelInfo[WPT_NUM_TRPT_CHANNEL];
146} wpt_log_data_stall_type;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +0530148
Jeff Johnson295189b2012-06-20 16:38:30 -0700149//pPkt is a pointer to wpt_packet
150#define WPAL_PACKET_SET_BD_POINTER(pPkt, pBd) ( (pPkt)->pBD = (pBd) )
151#define WPAL_PACKET_GET_BD_POINTER(pPkt) ( (pPkt)->pBD )
152//Access the physical address of BD
153#define WPAL_PACKET_SET_BD_PHYS(pPkt, pBdPhys) ( (pPkt)->pBDPhys = (pBdPhys) )
154#define WPAL_PACKET_GET_BD_PHYS(pPkt) ( (pPkt)->pBDPhys )
155#define WPAL_PACKET_SET_BD_LENGTH(pPkt, len) ( (pPkt)->BDLength = (len) )
156#define WPAL_PACKET_GET_BD_LENGTH(pPkt) ( (pPkt)->BDLength )
157#define WPAL_PACKET_SET_METAINFO_POINTER(pPkt, p) ( (pPkt)->pktMetaInfo = (p) )
158#define WPAL_PACKET_GET_METAINFO_POINTER(pPkt) ( (pPkt)->pktMetaInfo )
159#define WPAL_PACKET_SET_TYPE(pPkt, type) ( (pPkt)->pktType = (type) )
160#define WPAL_PACKET_GET_TYPE(pPkt) ( (pPkt)->pktType )
161#define WPAL_PACKET_SET_OS_STRUCT_POINTER(pPkt, pStruct) ( (pPkt)->pOSStruct = (pStruct) )
162#define WPAL_PACKET_GET_OS_STRUCT_POINTER(pPkt) ( (pPkt)->pOSStruct )
163#define WPAL_PACKET_IS_FLAT_BUF(pktType) ( (eWLAN_PAL_PKT_TYPE_RX_RAW == (pktType)) || \
164 (eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT == (pktType)) )
165
166/* RX RAW packet alloc fail due to out of resource CB function type */
167typedef void ( *wpalPacketLowPacketCB )( wpt_packet *pPacket, void *usrData );
168
169
170/*---------------------------------------------------------------------------
171 wpalPacketInit – Initialize all wpt_packet related objects. Allocate memory for wpt_packet.
172 Allocate memory for TX management frames and RX frames.
173 For our legacy UMAC, it is not needed because vos_packet contains wpt_packet.
174 Param:
175 pPalContext – A context PAL uses??
176 Return:
177 eWLAN_PAL_STATUS_SUCCESS -- success
178---------------------------------------------------------------------------*/
179wpt_status wpalPacketInit(void *pPalContext);
180
181/*---------------------------------------------------------------------------
182 wpalPacketClose – Free all allocated resource by wpalPacketInit.
183 For our legacy UMAC, it is not needed because vos_packet contains pal_packet.
184 Param:
185 pPalContext – A context PAL uses??
186 Return:
187 eWLAN_PAL_STATUS_SUCCESS -- success
188---------------------------------------------------------------------------*/
189wpt_status wpalPacketClose(void *pPalContext);
190
191
192/*---------------------------------------------------------------------------
193 wpalPacketAlloc – Allocate a wpt_packet from PAL.
194 Param:
195 pPalContext – A context PAL uses??
196 pktType – specify the type of wpt_packet to allocate
197 nPktSize - specify the maximum size of the packet buffer.
198 Return:
199 A pointer to the wpt_packet. NULL means fail.
200---------------------------------------------------------------------------*/
201wpt_packet * wpalPacketAlloc(wpt_packet_type pktType, wpt_uint32 nPktSize,
202 wpalPacketLowPacketCB rxLowCB, void *usrdata);
203
204/*---------------------------------------------------------------------------
205 wpalPacketFree – Free a wpt_packet chain for one particular type.
206 Packet type is carried in wpt_packet structure.
207 Param:
208 pPalContext – A context PAL uses??
209 pPkt - pointer to a packet to be freed.
210 Return:
211 eWLAN_PAL_STATUS_SUCCESS - success
212---------------------------------------------------------------------------*/
213wpt_status wpalPacketFree(wpt_packet *pPkt);
214
215/*---------------------------------------------------------------------------
216 wpalPacketGetLength – Get number of bytes in a wpt_packet.
217 Param:
218 pPalContext – PAL context returned from PAL open
219 pPkt - pointer to a packet to be freed.
220 Return:
221 Length of the data include layer-2 headers. For example, if the frame is 802.3,
222 the length includes the ethernet header.
223---------------------------------------------------------------------------*/
224wpt_uint32 wpalPacketGetLength(wpt_packet *pPkt);
225
226/*---------------------------------------------------------------------------
227 wpalPacketRawTrimHead – Move the starting offset and reduce packet length.
228 The function can only be used with raw packets,
229 whose buffer is one piece and allocated by WLAN driver.
230 Param:
231 pPkt - pointer to a wpt_packet.
232 size – number of bytes to take off the head.
233 Return:
234 eWPAL_STATUS_SUCCESS - success. Fail otherwise.
235---------------------------------------------------------------------------*/
236wpt_status wpalPacketRawTrimHead(wpt_packet *pPkt, wpt_uint32 size);
237
238/*---------------------------------------------------------------------------
239 wpalPacketRawTrimTail – reduce the length of the packet. The function can
240 only be used with raw packets, whose buffer is one piece and
241 allocated by WLAN driver. This also reduce the length of the packet.
242 Param:
243 pPkt - pointer to a wpt_packet.
244 size – number of bytes to take of the packet length
245 Return:
246 eWLAN_PAL_STATUS_SUCCESS – success. Otherwise fail.
247---------------------------------------------------------------------------*/
248wpt_status wpalPacketRawTrimTail(wpt_packet *pPkt, wpt_uint32 size);
249
250
251/*---------------------------------------------------------------------------
252 wpalPacketGetRawBuf – Return the starting buffer's virtual address for the RAW flat buffer
253 It is inline in hope of faster implementation for certain platform.
254 Param:
255 pPkt - pointer to a wpt_packet.
256 Return:
257 NULL - fail.
258 Otherwise the address of the starting of the buffer
259---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi08880832012-10-25 11:49:30 -0700260extern wpt_uint8 *wpalPacketGetRawBuf(wpt_packet *pPkt);
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
262
263/*---------------------------------------------------------------------------
264 wpalPacketSetRxLength – Set the valid data length on a RX packet. This function must
265 be called once per RX packet per receiving. It indicates the available data length from
266 the start of the buffer.
267 Param:
268 pPkt - pointer to a wpt_packet.
269 Return:
270 NULL - fail.
271 Otherwise the address of the starting of the buffer
272---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi08880832012-10-25 11:49:30 -0700273extern wpt_status wpalPacketSetRxLength(wpt_packet *pPkt, wpt_uint32 len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275
276/*---------------------------------------------------------------------------
277 wpalIteratorInit – Initialize an interator by updating pCur to first item.
278 Param:
279 pIter – pointer to a caller allocated wpt_iterator
280 pPacket – pointer to a wpt_packet
281 Return:
282 eWLAN_PAL_STATUS_SUCCESS - success
283---------------------------------------------------------------------------*/
284wpt_status wpalIteratorInit(wpt_iterator *pIter, wpt_packet *pPacket);
285
286/*---------------------------------------------------------------------------
287 wpalIteratorNext – Get the address for the next item
288 Param:
289 pIter – pointer to a caller allocated wpt_iterator
290 pPacket – pointer to a wpt_packet
291 ppAddr – Caller allocated pointer to return the address of the item. For DMA-able devices, this is the physical address of the item.
292 pLen – To return the number of bytes in the item.
293 Return:
294 eWLAN_PAL_STATUS_SUCCESS - success
295---------------------------------------------------------------------------*/
296wpt_status wpalIteratorNext(wpt_iterator *pIter, wpt_packet *pPacket, void **ppAddr, wpt_uint32 *pLen);
297
298
299/*---------------------------------------------------------------------------
300 wpalLockPacketForTransfer – Packet must be locked before transfer can begin,
301 the lock will ensure that the DMA engine has access to the data packet
302 in a cache coherent manner
303
304 Param:
305 pPacket – pointer to a wpt_packet
306
307 Return:
308 eWLAN_PAL_STATUS_SUCCESS - success
309---------------------------------------------------------------------------*/
310wpt_status wpalLockPacketForTransfer( wpt_packet *pPacket);
311
312/*---------------------------------------------------------------------------
313 wpalUnlockPacket – Once the transfer has been completed the packet should
314 be unlocked so that normal operation may resume
315 Param:
316 pPacket – pointer to a wpt_packet
317
318 Return:
319 eWLAN_PAL_STATUS_SUCCESS - success
320---------------------------------------------------------------------------*/
321wpt_status wpalUnlockPacket( wpt_packet *pPacket);
322
323/*---------------------------------------------------------------------------
324 wpalPacketGetFragCount – Get count of memory chains (fragments)
325 in a packet
326 Param:
327 pPacket – pointer to a wpt_packet
328
329 Return:
330 memory fragment count in a packet
331---------------------------------------------------------------------------*/
332wpt_int32 wpalPacketGetFragCount(wpt_packet *pPkt);
333
334/*---------------------------------------------------------------------------
335 wpalIsPacketLocked – Check whether the Packet is locked for DMA.
336 Param:
337 pPacket – pointer to a wpt_packet
338
339 Return:
340 eWLAN_PAL_STATUS_SUCCESS
341 eWLAN_PAL_STATUS_E_FAILURE
342 eWLAN_PAL_STATUS_E_INVAL
343---------------------------------------------------------------------------*/
344wpt_status wpalIsPacketLocked( wpt_packet *pPacket);
345
Gopichand Nakkalaa2cb10c2013-05-03 17:48:29 -0700346/*---------------------------------------------------------------------------
347 wpalGetNumRxRawPacket Query available RX RAW total buffer count
348 param:
349 numRxResource pointer of queried value
350
351 return:
352 eWLAN_PAL_STATUS_SUCCESS
353---------------------------------------------------------------------------*/
354wpt_status wpalGetNumRxRawPacket(wpt_uint32 *numRxResource);
355
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700356/*---------------------------------------------------------------------------
Mihir Sheted183cef2014-09-26 19:17:56 +0530357 wpalGetNumRxPacketAllocFailures Get number of times packet alloc failed
358 numRxResource pointer of queried value
359
360 return:
361 eWLAN_PAL_STATUS_SUCCESS
362---------------------------------------------------------------------------*/
363wpt_status wpalGetNumRxPacketAllocFailures(wpt_uint32 *numRxResource);
364
365/*---------------------------------------------------------------------------
Mihir Shete058fcff2014-06-26 18:54:06 +0530366 wpalGetNumRxFreePacket Query available RX Free buffer count
367 param:
368 numRxResource pointer of queried value
369
370 return:
371 WPT_STATUS
372---------------------------------------------------------------------------*/
373wpt_status wpalGetNumRxFreePacket(wpt_uint32 *numRxResource);
374
375/*---------------------------------------------------------------------------
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700376 wpalPacketStallUpdateInfo – Update each channel information when stall
377 detected, also power state and free resource count
378
379 Param:
380 powerState ? WLAN system power state when stall detected
381 numFreeBd ? Number of free resource count in HW
382 channelInfo ? Each channel specific information when stall happen
383 channelNum ? Channel number update information
384
385 Return:
386 NONE
387
388---------------------------------------------------------------------------*/
389void wpalPacketStallUpdateInfo
390(
391 v_U32_t *powerState,
392 v_U32_t *numFreeBd,
393 wpt_log_data_stall_channel_type *channelInfo,
394 v_U8_t channelNum
395);
396
Madan Mohan Koyyalamudi62080282013-08-05 12:51:17 +0530397#ifdef FEATURE_WLAN_DIAG_SUPPORT
Bansidhar Gopalachari609b79e2013-07-31 17:03:15 -0700398/*---------------------------------------------------------------------------
399 wpalPacketStallDumpLog – Trigger to send log packet to DIAG
400 Updated transport system information will be sent to DIAG
401
402 Param:
403 NONE
404
405 Return:
406 NONE
407
408---------------------------------------------------------------------------*/
409void wpalPacketStallDumpLog
410(
411 void
412);
413#endif /* FEATURE_WLAN_DIAG_SUPPORT */
414
Mihir Shete2187b8c2015-03-18 16:54:29 +0530415/*---------------------------------------------------------------------------
416 wpalLogPktSerialize - Serialize Logging data to logger thread
417
418 Param:
419 wpt_packet pFrame - The packet which contains the logging data.
420 This packet has to be a VALID packet, as this
421 API will not do any checks on the validity of
422 the packet.
423
424 Return:
425 NONE
426
427---------------------------------------------------------------------------*/
428void wpalLogPktSerialize
429(
430 wpt_packet *pFrame
431);
Mihir Shete5affadc2015-05-29 20:54:57 +0530432
433
434/*---------------------------------------------------------------------------
435 wpalFwLogPktSerialize - Serialize Logging data to logger thread
436
437 Param:
438 wpt_packet pFrame - The packet which contains the logging data.
439 This packet has to be a VALID packet, as this
440 API will not do any checks on the validity of
441 the packet.
442
443 Return:
444 NONE
445
446---------------------------------------------------------------------------*/
447void wpalFwLogPktSerialize
448(
Hanumantha Reddy Pothulae00a7e22015-09-15 20:11:30 +0530449 wpt_packet *pFrame, wpt_uint32 pktType
Mihir Shete5affadc2015-05-29 20:54:57 +0530450);
Sushant Kaushik33200572015-08-05 16:46:20 +0530451
452/*---------------------------------------------------------------------------
453 wpalPerPktSerialize - Serialize perpkt data to logger thread
454
455 Param:
456
457
458 Return:
459 NONE
460
461---------------------------------------------------------------------------*/
462void wpalPerPktSerialize
463(
464 void *perPktStat
465);
466
Bhargav Shah7dbfb6f2016-02-12 20:49:58 +0530467/*---------------------------------------------------------------------------
468 wpalGetOSPktHead – Get the head of OS spacific socket buffer
469 Param:
470 pPacket – pointer to a wpt_packet
471
472 Return:
473 void* - success
474---------------------------------------------------------------------------*/
475void* wpalGetOSPktHead( wpt_packet *pPacket);
476
477/*---------------------------------------------------------------------------
478 wpalGetOSPktend – Get end pointer of OS spacific socket buffer
479 Param:
480 pPacket – pointer to a wpt_packet
481
482 Return:
483 void* - success
484---------------------------------------------------------------------------*/
485void* wpalGetOSPktend( wpt_packet *pPacket);
486
487/*---------------------------------------------------------------------------
488 wpalRecoverTail – recover currupted skb tail.
489 Param:
490 pPacket – pointer to a wpt_packet
491
492 Return:
493 void - success
494---------------------------------------------------------------------------*/
495void wpalRecoverTail( wpt_packet *pPacket);
496
Jeff Johnson295189b2012-06-20 16:38:30 -0700497#endif // __WLAN_QCT_PAL_PACKET_H