OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / hardware / ti / wlan / wl1271 / platforms / os / common / inc / RxBuf.h
1 /*
2  * RxBuf.h
3  *
4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.      
5  * All rights reserved.                                                  
6  *                                                                       
7  * Redistribution and use in source and binary forms, with or without    
8  * modification, are permitted provided that the following conditions    
9  * are met:                                                              
10  *                                                                       
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         
16  *    distribution.                                                      
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.      
20  *                                                                       
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.
32  */
33
34
35 /***************************************************************************/
36 /*                                                                                                                                                 */
37 /*        MODULE:       buf.h                                                                                                  */
38 /*    PURPOSE:  manages the allocation/free and field access of the BUF    */
39 /*                                                                                                                                                 */
40 /***************************************************************************/
41 #ifndef _BUF_H_
42 #define _BUF_H_
43
44 #include "tidef.h"
45 #include "queue.h"
46 #include "public_descriptors.h"
47
48
49
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 */
52
53
54
55 /**
56  * \brief Buffer for Tx/Rx packets 
57  */ 
58 typedef void BUF, *PBUF;
59
60 /* Packet types */
61
62
63 /**
64  * \def RX_BUF_DATA
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
66  */
67 #define RX_BUF_DATA(pBuf)   ((void*)((TI_UINT8 *)pBuf + sizeof(RxIfDescriptor_t)))
68 /**
69  * \def RX_BUF_LEN
70  * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the WLAN packet
71  */
72 #define RX_BUF_LEN(pBuf)    ( (((RxIfDescriptor_t *)(pBuf))->length << 2) -  \
73                               ((RxIfDescriptor_t *)(pBuf))->extraBytes -     \
74                               sizeof(RxIfDescriptor_t) )
75
76 /**
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
79  */
80 #define RX_ETH_PKT_DATA(pBuf)   *((void **)(((TI_UINT32)pBuf + sizeof(RxIfDescriptor_t) + 2) & ~3))
81 /**
82  * \def RX_ETH_PKT_LEN
83  * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the ETH packet
84  */
85 #define RX_ETH_PKT_LEN(pBuf)    *((TI_UINT32 *)(((TI_UINT32)pBuf + sizeof(RxIfDescriptor_t) + 6) & ~3))
86
87
88 /** \brief BUF Allocation
89  * 
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
94  * 
95  * \par Description
96  * This function allocates BUF element for Tx/Rx packet
97  * 
98  * \sa
99  */ 
100 BUF* RxBufAlloc         (TI_HANDLE hOs, TI_UINT32 len, PacketClassTag_e ePacketClassTag);
101
102
103 /** \brief BUF Free
104  * 
105  * \param  hOs          - OS module object handle
106  * \param  pWbuf        - Pointer to WBUF which was previously created by user
107  * \return void
108  * 
109  * \par Description
110  * This function frees the memory allocated for BUF element
111  * 
112  * \sa
113  */ 
114 void  RxBufFree          (TI_HANDLE hOs, void* pBuf);
115
116
117 /** \brief BUF Free
118  * 
119  * \param  hOs          - OS module object handle
120  * \param  pWbuf        - Pointer to WBUF which was previously created by user
121  * \return void
122  * 
123  * \par Description
124  * This function increment the start address of data held in BUF element in len.
125  * 
126  * \sa
127  */ 
128 void  RxBufReserve       (TI_HANDLE hOs, void* pBuf, TI_UINT32 len); 
129
130 #endif
131