4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name Texas Instruments nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /***************************************************************************/
38 /* PURPOSE: manages the allocation/free and field access of the BUF */
40 /***************************************************************************/
46 #include "public_descriptors.h"
50 #define WSPI_PAD_BYTES 16 /* Add padding before data buffer for WSPI overhead */
51 #define PAYLOAD_ALIGN_PAD_BYTES 4 /* Add an extra word for alignment the MAC payload in case of QoS MSDU */
56 * \brief Buffer for Tx/Rx packets
58 typedef void BUF, *PBUF;
65 * \brief Macro which gets a pointer to BUF packet header and returns the pointer to the start address of the WLAN packet's data
67 #define RX_BUF_DATA(pBuf) ((void*)((TI_UINT8 *)pBuf + sizeof(RxIfDescriptor_t)))
70 * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the WLAN packet
72 #define RX_BUF_LEN(pBuf) ( (((RxIfDescriptor_t *)(pBuf))->length << 2) - \
73 ((RxIfDescriptor_t *)(pBuf))->extraBytes - \
74 sizeof(RxIfDescriptor_t) )
77 * \def RX_ETH_PKT_DATA
78 * \brief Macro which gets a pointer to BUF packet header and returns the pointer to the start address of the ETH packet's data
80 #define RX_ETH_PKT_DATA(pBuf) *((void **)(((TI_UINT32)pBuf + sizeof(RxIfDescriptor_t) + 2) & ~3))
83 * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the ETH packet
85 #define RX_ETH_PKT_LEN(pBuf) *((TI_UINT32 *)(((TI_UINT32)pBuf + sizeof(RxIfDescriptor_t) + 6) & ~3))
88 /** \brief BUF Allocation
90 * \param hOs - OS module object handle
91 * \param len - Length of allocated WBUF
92 * \param ePacketClassTag - The RX packet type (used only in EMP)
93 * \return On success: Pointer to WBUF ; Otherwise: NULL
96 * This function allocates BUF element for Tx/Rx packet
100 BUF* RxBufAlloc (TI_HANDLE hOs, TI_UINT32 len, PacketClassTag_e ePacketClassTag);
105 * \param hOs - OS module object handle
106 * \param pWbuf - Pointer to WBUF which was previously created by user
110 * This function frees the memory allocated for BUF element
114 void RxBufFree (TI_HANDLE hOs, void* pBuf);
119 * \param hOs - OS module object handle
120 * \param pWbuf - Pointer to WBUF which was previously created by user
124 * This function increment the start address of data held in BUF element in len.
128 void RxBufReserve (TI_HANDLE hOs, void* pBuf, TI_UINT32 len);