1 /** \file Core_AdaptTx.c
2 * \brief CORE Adaptation Ctrl layer implementation
3 *
4 * \see CORE_AdaptTx.h
5 */
6 /****************************************************************************
7 **+-----------------------------------------------------------------------+**
8 **| |**
9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
10 **| All rights reserved. |**
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 /* */
43 /* MODULE: Core_AdaptTx.c */
44 /* PURPOSE: CORE Adaptation Tx layer implementation */
45 /* */
46 /***************************************************************************/
47 #include "report.h"
48 #include "osApi.h"
49
50 #include "paramOut.h"
51 #include "siteHash.h"
52 #include "configMgr.h"
53 #include "whalCtrl_api.h"
54 #include "Core_AdaptTx.h"
55 #include "utils.h"
56 #include "DataCtrl_Api.h"
57 #include "TNETW_Driver_api.h"
58
59 /* Globals */
60 TI_HANDLE CORE_AdaptTx_handle=NULL;
61
62 /* definitions */
63
64
65 /* Local Macros */
66
67
68 /* Local functions definitions*/
69
70
71 /****************************************************************************************
72 * CORE_AdaptTx_Create *
73 ****************************************************************************************
74 DESCRIPTION: CORE ADAPTER TX CREATION
75
76 INPUT: TI_HANDLE hOs
77 OUTPUT:
78
79 RETURN: OK on success, NOK on failure
80
81 ************************************************************************/
CORE_AdaptTx_Create(TI_HANDLE hOs)82 TI_HANDLE CORE_AdaptTx_Create(TI_HANDLE hOs)
83 {
84 CORE_AdaptTx_t *pCORE_AdaptTx_handle;
85
86 pCORE_AdaptTx_handle = os_memoryAlloc (hOs, sizeof(CORE_AdaptTx_t));
87 if (pCORE_AdaptTx_handle == NULL)
88 return NULL;
89
90 pCORE_AdaptTx_handle->hOs = hOs;
91
92 return (TI_HANDLE)pCORE_AdaptTx_handle;
93 }
94
95
96 /****************************************************************************************
97 * CORE_AdaptTx_Config *
98 ****************************************************************************************
99 DESCRIPTION: CORE ADAPTER TX CONFIGURATION
100
101 INPUT: TI_HANDLE hOs
102 OUTPUT:
103
104 RETURN: OK on success, NOK on failure
105
106 ************************************************************************/
CORE_AdaptTx_Config(TI_HANDLE CORE_AdaptTx_handle,Core_AdaptTx_config_t * pCore_AdaptTx_config,txDataInitParams_t * txDataInitParams)107 int CORE_AdaptTx_Config (TI_HANDLE CORE_AdaptTx_handle, Core_AdaptTx_config_t *pCore_AdaptTx_config,txDataInitParams_t *txDataInitParams)
108 {
109 CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t*)CORE_AdaptTx_handle;
110
111 /*
112 * handles
113 */
114 pCore_AdaptTx->hReport = pCore_AdaptTx_config->hReport;
115 pCore_AdaptTx->hMemMgr = pCore_AdaptTx_config->hMemMgr;
116 pCore_AdaptTx->hTnetwDrv = pCore_AdaptTx_config->hTnetwDrv;
117 pCore_AdaptTx->hTxData = pCore_AdaptTx_config->hTxData;
118 pCore_AdaptTx->hCtrlData = pCore_AdaptTx_config->hCtrlData;
119
120 return OK;
121 }
122
123
124 /****************************************************************************************
125 * CORE_AdaptTx_Destroy *
126 ****************************************************************************************
127 DESCRIPTION: CORE ADAPTER TX DESTRUCTION
128
129 INPUT: TI_HANDLE hCore_AdaptTx - Passed even if its is global variable
130
131 OUTPUT:
132
133 RETURN: OK on success, NOK on failure
134
135 ************************************************************************/
CORE_AdaptTx_Destroy(TI_HANDLE hCore_AdaptTx)136 int CORE_AdaptTx_Destroy (TI_HANDLE hCore_AdaptTx)
137 {
138 CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)hCore_AdaptTx;
139 int status = OK;
140
141 if(hCore_AdaptTx == NULL)
142 {
143 return OK;
144 }
145
146 /* free the CORE_AdaptCtrl data structure*/
147 os_memoryFree (pCore_AdaptTx->hOs, pCore_AdaptTx, sizeof(CORE_AdaptTx_t));
148
149 return status;
150 }
151
152
153 /****************************************************************************************
154 * CORE_AdaptTx_SendPacket *
155 ****************************************************************************************
156 DESCRIPTION: CORE ADAPTER TX SendPacket
157
158 INPUT: TI_HANDLE hCore_AdaptTx - Passed even if its is global variable
159
160 OUTPUT:
161
162 RETURN: OK on success, NOK on failure
163
164 ************************************************************************/
165
166
CORE_AdaptTx_SendPacket(TI_HANDLE hCore_AdaptTx,UINT8 TxQid,mem_MSDU_T * pMsdu,txData_attr_t * pTxAttr,UINT32 packetId,UINT32 msduTimeToExpiry)167 TI_STATUS CORE_AdaptTx_SendPacket (TI_HANDLE hCore_AdaptTx,
168 UINT8 TxQid,
169 mem_MSDU_T* pMsdu,
170 txData_attr_t* pTxAttr,
171 UINT32 packetId,
172 UINT32 msduTimeToExpiry )
173 {
174 void *aFrame;
175 UINT16 aLength;
176 UINT8 aQueueId;
177 UINT8 aTxRateClassId;
178 CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)hCore_AdaptTx;
179
180 /*
181 * handling send packet parameters
182 */
183
184 /* Pointer to the frame actual data (right after TNETWIF_WRITE_OFFSET_BYTES and descriptor) */
185 aFrame = (void *)((UINT8*)memMgr_BufData(pMsdu->firstBDPtr) + TX_TOTAL_OFFSET_BEFORE_DATA);
186
187 /*
188 * MSDU length. Measured from the first byte of the MAC header
189 * to the last byte of the frame body.
190 */
191 aLength = memMgr_MsduDataSize(pMsdu);
192
193 /*
194 * Transmit queue as defined in ConfigureQueue
195 */
196 aQueueId = TxQid;
197
198 /*
199 * Transmit rate class ID defined in txRatePolicy
200 */
201 aTxRateClassId = pTxAttr->txRatePolicyId;
202
203 return TnetwDrv_txXfer_sendPacket (pCore_AdaptTx->hTnetwDrv,
204 aFrame,
205 aLength,
206 aQueueId,
207 aTxRateClassId,
208 pTxAttr->HwRate,
209 FALSE, /* more indication, currently ignored by GWSI */
210 packetId,
211 0,
212 msduTimeToExpiry,
213 NULL);
214 }
215
216
217 /* --------------------------------- Call Back ---------------------------------------------------*/
218
219 /****************************************************************************************
220 * SendPacketComplete *
221 ****************************************************************************************
222 DESCRIPTION: CORE ADAPTER TX Tx Complete callback
223
224 INPUT:
225
226 OUTPUT:
227
228 RETURN:
229
230 ************************************************************************/
SendPacketComplete(TI_HANDLE hUser,systemStatus_e aStatus,UINT32 aPacketId,UINT32 aRate,UINT8 aAckFailures,UINT32 actualDurationInAir,UINT32 fwHandlingTime,UINT32 mediumDelay)231 void SendPacketComplete (TI_HANDLE hUser,
232 systemStatus_e aStatus,
233 UINT32 aPacketId,
234 UINT32 aRate,
235 UINT8 aAckFailures,
236 UINT32 actualDurationInAir,
237 UINT32 fwHandlingTime,
238 UINT32 mediumDelay)
239 {
240 CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)CORE_AdaptTx_handle;
241 txCompleteAttr_t txCompleteAttr;
242
243 WLAN_REPORT_INFORMATION(pCore_AdaptTx->hReport, CTRL_DATA_MODULE_LOG,
244 ("SendPacketComplete: aStatus = %d\n\n",aStatus));
245
246 /*
247 * Call the core CB (TI CORE)
248 */
249 txCompleteAttr.status = aStatus;
250 txCompleteAttr.packetId = aPacketId;
251 txCompleteAttr.rate = aRate;
252 txCompleteAttr.ackFailures = aAckFailures;
253 txCompleteAttr.actualDurationInAir = actualDurationInAir;
254 txCompleteAttr.fwHandlingTime = fwHandlingTime;
255 txCompleteAttr.mediumDelay = mediumDelay;
256
257 ctrlData_txCompleteStatus (pCore_AdaptTx->hCtrlData, &txCompleteAttr);
258 }
259
260
261 /****************************************************************************************
262 * SendPacketTransfer *
263 ****************************************************************************************
264 DESCRIPTION: CORE ADAPTER TX SendPacketTransfer callback
265
266 INPUT:
267
268 OUTPUT:
269
270 RETURN:
271
272 ************************************************************************/
SendPacketTransfer(TI_HANDLE hUser,UINT32 aPacketId)273 void SendPacketTransfer (TI_HANDLE hUser, UINT32 aPacketId)
274 {
275 CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t*)CORE_AdaptTx_handle;
276
277 txData_sendPacketTransfer (pCore_AdaptTx->hTxData, aPacketId);
278 }
279
280
281 /****************************************************************************************
282 * SendPacketDebug *
283 ****************************************************************************************
284 DESCRIPTION: CORE ADAPTER TX SendPacketDebug callback
285
286 INPUT:
287
288 OUTPUT:
289
290 RETURN:
291
292 ************************************************************************/
293 #ifdef TI_DBG
SendPacketDebug(TI_HANDLE hUser,UINT32 uPacketId,UINT32 uDebugInfo)294 void SendPacketDebug (TI_HANDLE hUser, UINT32 uPacketId, UINT32 uDebugInfo)
295 {
296 CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t *)CORE_AdaptTx_handle;
297
298 txData_sendPacketDebug (pCore_AdaptTx->hTxData, uPacketId, uDebugInfo);
299 }
300 #endif
301