|
1 /* |
|
2 * RxBuf.h |
|
3 * |
|
4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. |
|
5 * All rights reserved. |
|
6 * |
|
7 * This program and the accompanying materials are made available under the |
|
8 * terms of the Eclipse Public License v1.0 or BSD License which accompanies |
|
9 * this distribution. The Eclipse Public License is available at |
|
10 * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below. |
|
11 * |
|
12 * Redistribution and use in source and binary forms, with or without |
|
13 * modification, are permitted provided that the following conditions |
|
14 * are met: |
|
15 * |
|
16 * * Redistributions of source code must retain the above copyright |
|
17 * notice, this list of conditions and the following disclaimer. |
|
18 * * Redistributions in binary form must reproduce the above copyright |
|
19 * notice, this list of conditions and the following disclaimer in |
|
20 * the documentation and/or other materials provided with the |
|
21 * distribution. |
|
22 * * Neither the name Texas Instruments nor the names of its |
|
23 * contributors may be used to endorse or promote products derived |
|
24 * from this software without specific prior written permission. |
|
25 * |
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
37 */ |
|
38 |
|
39 |
|
40 /***************************************************************************/ |
|
41 /* */ |
|
42 /* MODULE: buf.h */ |
|
43 /* PURPOSE: manages the allocation/free and field access of the BUF */ |
|
44 /* */ |
|
45 /***************************************************************************/ |
|
46 #ifndef _BUF_H_ |
|
47 #define _BUF_H_ |
|
48 |
|
49 #include "tidef.h" |
|
50 #include "queue.h" |
|
51 #include "public_descriptors.h" |
|
52 |
|
53 |
|
54 |
|
55 #define WSPI_PAD_BYTES 16 /* Add padding before data buffer for WSPI overhead */ |
|
56 #define PAYLOAD_ALIGN_PAD_BYTES 4 /* Add an extra word for alignment the MAC payload in case of QoS MSDU */ |
|
57 |
|
58 |
|
59 |
|
60 /** |
|
61 * \brief Buffer for Tx/Rx packets |
|
62 */ |
|
63 typedef void BUF, *PBUF; |
|
64 |
|
65 /* Packet types */ |
|
66 |
|
67 |
|
68 /** |
|
69 * \def RX_BUF_DATA |
|
70 * \brief Macro which gets a pointer to BUF packet header and returns the pointer to the start address of the WLAN packet's data |
|
71 */ |
|
72 #define RX_BUF_DATA(pBuf) ((void*)((TI_UINT8 *)pBuf + sizeof(RxIfDescriptor_t))) |
|
73 /** |
|
74 * \def RX_BUF_LEN |
|
75 * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the WLAN packet |
|
76 */ |
|
77 #define RX_BUF_LEN(pBuf) ((((RxIfDescriptor_t *)(pBuf))->length) << 2 ) - \ |
|
78 (((((RxIfDescriptor_t *)(pBuf))->status) & RX_DESC_LENGTH_LESS_3B) >> 6) - \ |
|
79 sizeof(RxIfDescriptor_t) |
|
80 |
|
81 /** |
|
82 * \def RX_ETH_PKT_DATA |
|
83 * \brief Macro which gets a pointer to BUF packet header and returns the pointer to the start address of the ETH packet's data |
|
84 */ |
|
85 #define RX_ETH_PKT_DATA(pBuf) *((void*)((TI_UINT8 *)pBuf + sizeof(RxIfDescriptor_t))) |
|
86 /** |
|
87 * \def RX_ETH_PKT_LEN |
|
88 * \brief Macro which gets a pointer to BUF packet header and returns the buffer length (without Rx Descriptor) of the ETH packet |
|
89 */ |
|
90 #define RX_ETH_PKT_LEN(pBuf) *((void*)((TI_UINT8 *)pBuf + sizeof(RxIfDescriptor_t) + 4)) |
|
91 |
|
92 |
|
93 /** \brief BUF Allocation |
|
94 * |
|
95 * \param hOs - OS module object handle |
|
96 * \param len - Length of allocated WBUF |
|
97 * \return On success: Pointer to WBUF ; Otherwise: NULL |
|
98 * |
|
99 * \par Description |
|
100 * This function allocates BUF element for Tx/Rx packet |
|
101 * |
|
102 * \sa |
|
103 */ |
|
104 BUF* RxBufAlloc (TI_HANDLE hOs, TI_UINT32 len); |
|
105 |
|
106 |
|
107 /** \brief BUF Free |
|
108 * |
|
109 * \param hOs - OS module object handle |
|
110 * \param pWbuf - Pointer to WBUF which was previously created by user |
|
111 * \return void |
|
112 * |
|
113 * \par Description |
|
114 * This function frees the memory allocated for BUF element |
|
115 * |
|
116 * \sa |
|
117 */ |
|
118 void RxBufFree (TI_HANDLE hOs, void* pBuf); |
|
119 |
|
120 |
|
121 /** \brief BUF Free |
|
122 * |
|
123 * \param hOs - OS module object handle |
|
124 * \param pWbuf - Pointer to WBUF which was previously created by user |
|
125 * \return void |
|
126 * |
|
127 * \par Description |
|
128 * This function increment the start address of data held in BUF element in len. |
|
129 * |
|
130 * \sa |
|
131 */ |
|
132 void RxBufReserve (TI_HANDLE hOs, void* pBuf, TI_UINT32 len); |
|
133 |
|
134 #endif |
|
135 |