PageRenderTime 45ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/FW_Transfer/DebugTrace_Xfer/DebugTraceXfer.c

http://github.com/CyanogenMod/cm-kernel
C | 662 lines | 299 code | 111 blank | 252 comment | 22 complexity | 1a44a0fa1fc716fe7aeb350343abd171 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 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. #ifdef TI_DBG
  36. #include "FwEvent_api.h"
  37. #include "whalParams.h"
  38. #include "DebugTraceXfer_api.h"
  39. #include "report.h"
  40. #include "whalBus_Defs.h"
  41. #include "TNETWIF.h"
  42. #include "utils.h"
  43. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  44. #include "memMngrEx.h"
  45. #endif
  46. #include "whalCommon.h"
  47. /*****************************************************************************
  48. ** UDP Packet Build **
  49. *****************************************************************************/
  50. #define Ether_Type 0x0800 /* For IP Protocol */
  51. /* This is an Ethernet Version 2 frame: 14 Byte */
  52. typedef struct {
  53. UINT8 ether_dst[6];
  54. UINT8 ether_src[6];
  55. UINT16 ether_Type;
  56. } etherHeader;
  57. #define IP_Version 0x45 /* IP Ver - 4 Length Of IP Header 5 UINT32 (20 Byte) */
  58. #define IP_TimeToLive 128 /* limit the number of Router Hops */
  59. #define IP_Protocol 0x11 /* UDP protocol */
  60. /* This is an IP frame: 20 Byte */
  61. typedef struct
  62. {
  63. UINT8 IpVer;
  64. UINT8 TypeOfService;
  65. UINT16 Totallen;
  66. UINT16 Indentification;
  67. UINT16 FragOffset;
  68. UINT8 TimeToLive;
  69. UINT8 protocol;
  70. UINT16 csum;
  71. UINT8 src[4];
  72. UINT8 dst[4];
  73. } ipstruct;
  74. #define Source_Port 0
  75. #define Destination_Port 5555
  76. /* This is a UDP frame: 8 Byte */
  77. typedef struct {
  78. UINT16 src_port;
  79. UINT16 dst_port;
  80. UINT16 UDP_len;
  81. UINT16 UDP_Csum;
  82. } UDPStruct;
  83. /* This is a Trace Frame:*/
  84. #pragma pack(1)
  85. typedef struct {
  86. etherHeader Ether_Header;
  87. ipstruct IP_Header;
  88. UDPStruct UDP_Header;
  89. } TraceFrame;
  90. #pragma pack()
  91. /*****************************************************************************
  92. ** Structures **
  93. *****************************************************************************/
  94. typedef enum
  95. {
  96. DEBUG_TRACE_STATE_IDLE,
  97. DEBUG_TRACE_STATE_READ_BUF,
  98. DEBUG_TRACE_STATE_ACK_EVENT
  99. } debugTraceState_e;
  100. /*
  101. * DebugTraceXfer: The Debug Trace Object
  102. */
  103. typedef struct
  104. {
  105. TraceFrame FrameHeader; /* Do Not Change Place */
  106. /* use a struct to read buffers from the bus - used for extra bytes reserving */
  107. PADDING (UINT32 debugWords[TRACE_BUFFER_MAX_SIZE * 2]) /* *2 for the 2 buffers */
  108. BOOL bDoPrint;
  109. BOOL bUdpSend;
  110. BOOL bSync; /* indicate if we are in Synch bus or not */
  111. UINT32 TraceBufferSize;
  112. UINT32 BufferOffset[2]; /* holds the offset of Buffer A and Buffer B */
  113. UINT8 currBuffer; /* switch between 0 and 1 according to the buffer used */
  114. debugTraceState_e state;
  115. TI_STATUS returnValue;
  116. TI_HANDLE hOs;
  117. TI_HANDLE hReport;
  118. TI_HANDLE hFwEvent;
  119. TI_HANDLE hMemMgr;
  120. TI_HANDLE hTNETWIF;
  121. } DebugTrace_t;
  122. /****************************************************************************
  123. * static function declaration
  124. ****************************************************************************/
  125. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  126. static void debugTrace_BuildFrame(DebugTrace_t *pDebugTrace, UINT8* MacAddress);
  127. #endif
  128. static void debugTrace_StateMachine(TI_HANDLE hDebugTrace,UINT8 module_id ,TI_STATUS status);
  129. /****************************************************************************
  130. * debugTrace_Create()
  131. *****************************************************************************
  132. * DESCRIPTION: Create
  133. *
  134. * INPUTS:
  135. *
  136. * RETURNS:
  137. *
  138. *****************************************************************************/
  139. TI_HANDLE debugTrace_Create(TI_HANDLE hOs)
  140. {
  141. DebugTrace_t *pDebugTrace;
  142. pDebugTrace = os_memoryAlloc(hOs, sizeof(DebugTrace_t));
  143. if (pDebugTrace == NULL)
  144. {
  145. WLAN_OS_REPORT(("debugTrace_Create: Error Creating Trace Buffer \n"));
  146. return NULL;
  147. }
  148. os_memoryZero(hOs, pDebugTrace, sizeof(DebugTrace_t));
  149. pDebugTrace->hOs = hOs;
  150. return((TI_HANDLE)pDebugTrace);
  151. }
  152. /****************************************************************************
  153. * debugTrace_Destroy()
  154. *****************************************************************************
  155. * DESCRIPTION: Destroy
  156. *
  157. * INPUTS:
  158. *
  159. * RETURNS:
  160. *
  161. *****************************************************************************/
  162. void debugTrace_Destroy(TI_HANDLE hDebugTrace)
  163. {
  164. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  165. if (pDebugTrace)
  166. {
  167. os_memoryFree(pDebugTrace->hOs, pDebugTrace, sizeof(DebugTrace_t));
  168. }
  169. }
  170. /****************************************************************************
  171. * debugTrace_Config()
  172. *****************************************************************************
  173. * DESCRIPTION: Config
  174. *
  175. * INPUTS:
  176. *
  177. * RETURNS:
  178. *
  179. *****************************************************************************/
  180. void debugTrace_Config(TI_HANDLE hDebugTrace, TI_HANDLE hWhalParams, TI_HANDLE hReport,
  181. TI_HANDLE hMemMgr, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent)
  182. {
  183. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  184. pDebugTrace->hReport = hReport;
  185. pDebugTrace->hMemMgr = hMemMgr;
  186. pDebugTrace->hTNETWIF = hTNETWIF;
  187. pDebugTrace->hFwEvent = hFwEvent;
  188. /* next 2 parameters are TRUE & FALSE by default but can be changed in run time */
  189. pDebugTrace->bUdpSend = FALSE;
  190. pDebugTrace->bDoPrint = TRUE;
  191. pDebugTrace->TraceBufferSize = whal_ParamsGetTraceBufferSize(hWhalParams);
  192. pDebugTrace->currBuffer = 0;
  193. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  194. /* Build Frame to be send to the OS */
  195. debugTrace_BuildFrame(pDebugTrace, whal_ParamsGetSrcMac(hWhalParams));
  196. #endif
  197. /* Enable Trace Interrupts - actual interrupts will be raised only after init phase */
  198. FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
  199. FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
  200. }
  201. /****************************************************************************
  202. * debugTrace_ConfigHw()
  203. *****************************************************************************
  204. * DESCRIPTION: Initialize the address to read the buffer from the FW
  205. *
  206. * INPUTS: hDebugTrace - Debug Trace object
  207. *
  208. * RETURNS:
  209. *
  210. *****************************************************************************/
  211. void debugTrace_ConfigHw(TI_HANDLE hDebugTrace,UINT32 TraceAddA, UINT32 TraceAddB)
  212. {
  213. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  214. pDebugTrace->BufferOffset[0] = TraceAddA;
  215. pDebugTrace->BufferOffset[1] = TraceAddB;
  216. WLAN_REPORT_INIT(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
  217. ("debugTrace_ConfigHw: Buffer A offSet =0x%x, Buffer B offSet =0x%x, TraceBufferSize = %d \n"
  218. ,pDebugTrace->BufferOffset[0], pDebugTrace->BufferOffset[1],pDebugTrace->TraceBufferSize));
  219. }
  220. /****************************************************************************
  221. * debugTrace_Event()
  222. *****************************************************************************
  223. * DESCRIPTION: Called upon an interrupt of debug trace kind.
  224. *
  225. * INPUTS: hDebugTrace - Debug Trace object
  226. *
  227. * RETURNS:
  228. *
  229. *****************************************************************************/
  230. TI_STATUS debugTrace_Event(TI_HANDLE hDebugTrace)
  231. {
  232. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  233. WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
  234. (" debugTrace_Event: Reading from Buffer %d \n",pDebugTrace->currBuffer));
  235. /* assume that we are in synch bus until otherwise is proven */
  236. pDebugTrace->bSync = TRUE;
  237. debugTrace_StateMachine(pDebugTrace,0,(TI_STATUS)0);
  238. return pDebugTrace->returnValue;
  239. }
  240. /****************************************************************************
  241. * debugTrace_StateMachine()
  242. ****************************************************************************
  243. * DESCRIPTION: Manage the Debug trace state machine
  244. *
  245. * The SM is running one event at a time (buffer A or B) .
  246. * The order of the states is always the same: IDLE --> READ_BUF --> ACK_EVENT
  247. * The difference is whether we are using Synch or Asynch API.
  248. * In the Synch case (SDIO) we are looping in the while-loop till we return to IDLE, and we return
  249. * to FwEvent module a TNETWIF_OK status.
  250. * In the Asynch case we use the SM CB to return to the SM after each Asynch call
  251. * (In that case the return status is TNETWIF_PENDING, and we are waiting for the CB).
  252. * In the Asynch case the FwEvent module gets TNETWIF_PENDING in return, and waits for
  253. * the FwEvent_EventComplete() call in order to move the FwEvent SM.
  254. *
  255. * INPUTS: hFwEvent - The object
  256. * module_id - not used (for CB API only)
  257. * status - not used (for CB API only)
  258. *
  259. * OUTPUT: None
  260. *
  261. * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync
  262. ****************************************************************************/
  263. static void debugTrace_StateMachine(TI_HANDLE hDebugTrace,UINT8 module_id ,TI_STATUS status)
  264. {
  265. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  266. pDebugTrace->returnValue = OK;
  267. while(pDebugTrace->returnValue != TNETWIF_PENDING)
  268. {
  269. switch(pDebugTrace->state)
  270. {
  271. case DEBUG_TRACE_STATE_IDLE:
  272. pDebugTrace->returnValue = TNETWIF_ReadMemOpt (pDebugTrace->hTNETWIF,
  273. pDebugTrace->BufferOffset[pDebugTrace->currBuffer],
  274. PADREAD (pDebugTrace->debugWords),
  275. pDebugTrace->TraceBufferSize,
  276. FW_EVENT_MODULE_ID,
  277. debugTrace_StateMachine,
  278. pDebugTrace);
  279. pDebugTrace->state = DEBUG_TRACE_STATE_READ_BUF;
  280. break;
  281. case DEBUG_TRACE_STATE_READ_BUF:
  282. /* Now, handle the buffer */
  283. /* Print on every Trace */
  284. if(pDebugTrace->bDoPrint)
  285. {
  286. debugTrace_Print(pDebugTrace);
  287. }
  288. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  289. /* Handle The Trace */
  290. if(pDebugTrace->bUdpSend)
  291. {
  292. debugTrace_handleBuffer(hDebugTrace);
  293. }
  294. #endif
  295. /*Trigger the FW when finishing handle the event */
  296. pDebugTrace->returnValue = TNETWIF_WriteRegOpt(pDebugTrace->hTNETWIF, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_DEBUG_ACK,
  297. FW_EVENT_MODULE_ID,debugTrace_StateMachine,pDebugTrace);
  298. pDebugTrace->state = DEBUG_TRACE_STATE_ACK_EVENT;
  299. break;
  300. case DEBUG_TRACE_STATE_ACK_EVENT:
  301. /* Handling of the event is done. Now switch to the next buffer for the next time */
  302. pDebugTrace->currBuffer = (++pDebugTrace->currBuffer) & 0x1; /* &0x1 is %2 */
  303. if (FALSE == pDebugTrace->bSync )
  304. {
  305. /* Async bus - call FwEvent for notifying the completion */
  306. FwEvent_EventComplete(pDebugTrace->hFwEvent, TNETWIF_OK);
  307. }
  308. else /* This is the Sync case and we return TNETWIF_OK */
  309. {
  310. pDebugTrace->returnValue = TNETWIF_OK;
  311. }
  312. /* Exit SM */
  313. pDebugTrace->state = DEBUG_TRACE_STATE_IDLE;
  314. return;
  315. /* break; */
  316. default:
  317. WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
  318. ("debugTrace_StateMachine: unKnown state !!!\n"));
  319. break;
  320. }
  321. }
  322. /* if we are here - we got TNETWIF_PENDING, so we are in Async mode */
  323. pDebugTrace->bSync = FALSE;
  324. if (pDebugTrace->returnValue == TNETWIF_ERROR)
  325. {
  326. WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
  327. ("debugTrace_StateMachine: rc = TNETWIF_ERROR in state %d \n",pDebugTrace->state));
  328. }
  329. }
  330. /****************************************************************************
  331. * debugTrace_Disable()
  332. *****************************************************************************
  333. * DESCRIPTION: disable receiving interrupts of this kind (debug trace)
  334. *
  335. * INPUTS: hDebugTrace - Debug Trace object
  336. *
  337. * RETURNS:
  338. *
  339. *****************************************************************************/
  340. void debugTrace_Disable(TI_HANDLE hDebugTrace)
  341. {
  342. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  343. FwEvent_Disable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
  344. FwEvent_Disable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
  345. WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
  346. ("whal_DebugTrace_t_Disable: Trace Disable \n"));
  347. }
  348. /****************************************************************************
  349. * debugTrace_Enable()
  350. *****************************************************************************
  351. * DESCRIPTION: Enables receiving interrupts of this kind (debug trace)
  352. *
  353. * INPUTS: hDebugTrace - Debug Trace object
  354. *
  355. * RETURNS:
  356. *
  357. *****************************************************************************/
  358. void debugTrace_Enable(TI_HANDLE hDebugTrace)
  359. {
  360. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  361. FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
  362. FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
  363. WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_CTRL_MODULE_LOG,
  364. ("whal_DebugTrace_tEnable: Trace Enable \n"));
  365. }
  366. /****************************************************************************
  367. * debugTrace_Print()
  368. *****************************************************************************
  369. * DESCRIPTION: Print the current buffer
  370. *
  371. * INPUTS: hDebugTrace - Debug Trace object
  372. *
  373. * RETURNS:
  374. *
  375. *****************************************************************************/
  376. void debugTrace_Print(TI_HANDLE hDebugTrace)
  377. {
  378. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  379. UINT32 index;
  380. WLAN_OS_REPORT(("Trace buffer size = %d\n",pDebugTrace->TraceBufferSize));
  381. for(index = 0; index < pDebugTrace->TraceBufferSize / 4 ; index+=2)
  382. {
  383. WLAN_OS_REPORT(("0x%08X 0x%08X\n",
  384. pDebugTrace->debugWords[index],
  385. pDebugTrace->debugWords[index+1]));
  386. }
  387. }
  388. /****************************************************************************
  389. * debugTrace_EnablePrint()
  390. *****************************************************************************
  391. * DESCRIPTION: enable printing on each interrupt
  392. *
  393. * INPUTS: hDebugTrace - Debug Trace object
  394. *
  395. * RETURNS:
  396. *
  397. *****************************************************************************/
  398. void debugTrace_EnablePrint(TI_HANDLE hDebugTrace)
  399. {
  400. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  401. pDebugTrace->bDoPrint = TRUE;
  402. WLAN_OS_REPORT(("whal_DebugTrace_t_EnablePrint: Print Enabled \n"));
  403. }
  404. /****************************************************************************
  405. * debugTrace_DisablePrint()
  406. *****************************************************************************
  407. * DESCRIPTION: disable printing on each interrupt
  408. *
  409. * INPUTS: hDebugTrace - Debug Trace object
  410. *
  411. * RETURNS:
  412. *
  413. *****************************************************************************/
  414. void debugTrace_DisablePrint(TI_HANDLE hDebugTrace)
  415. {
  416. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  417. pDebugTrace->bDoPrint = FALSE;
  418. WLAN_OS_REPORT(("whal_DebugTrace_t_DisablePrint: Print Disabled \n"));
  419. }
  420. /****************************************************************************
  421. * debugTrace_UdpEnable()
  422. *****************************************************************************
  423. * DESCRIPTION: enable sending udp on each interrupt
  424. *
  425. * INPUTS: hDebugTrace - Debug Trace object
  426. *
  427. * RETURNS:
  428. *
  429. *****************************************************************************/
  430. void debugTrace_UdpEnable(TI_HANDLE hDebugTrace)
  431. {
  432. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  433. pDebugTrace->bUdpSend = TRUE;
  434. WLAN_OS_REPORT(("whal_DebugTrace_t_UdpEnable: Enable UDP trace send\n"));
  435. }
  436. /****************************************************************************
  437. * debugTrace_UdpDisable()
  438. *****************************************************************************
  439. * DESCRIPTION: disable sending udp on each interrupt
  440. *
  441. * INPUTS: hDebugTrace - Debug Trace object
  442. *
  443. * RETURNS:
  444. *
  445. *****************************************************************************/
  446. void debugTrace_UdpDisable(TI_HANDLE hDebugTrace)
  447. {
  448. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  449. pDebugTrace->bUdpSend = FALSE;
  450. WLAN_OS_REPORT(("whal_DebugTrace_t_UdpEnable: Disable UDP trace send\n"));
  451. }
  452. #if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
  453. /****************************************************************************
  454. * debugTrace_handleBuffer()
  455. *****************************************************************************
  456. * DESCRIPTION:
  457. *
  458. * INPUTS: hDebugTrace - Debug Trace object
  459. *
  460. * RETURNS:
  461. *
  462. *****************************************************************************/
  463. void debugTrace_handleBuffer(TI_HANDLE hDebugTrace)
  464. {
  465. DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
  466. mem_MSDU_T *pMsdu;
  467. mem_BD_T *pBd;
  468. UINT8 *srcDataPtr;
  469. int Stt;
  470. int AcxMpduLen;
  471. /* The Msdu Len should be The IP total Length + the Ethernet header length */
  472. AcxMpduLen = wlan_ntohs(pDebugTrace->FrameHeader.IP_Header.Totallen)
  473. + sizeof(pDebugTrace->FrameHeader.Ether_Header);
  474. /*
  475. * allocate host msdu
  476. */
  477. Stt = wlan_memMngrAllocMSDU(pDebugTrace->hMemMgr, &pMsdu, AcxMpduLen, TRACE_BUFFER_MODULE);
  478. if (Stt != OK)
  479. {
  480. WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_DATA_MODULE_LOG,
  481. ("whal_DebugTrace_t_handleBuffer: wlan_memMngrAllocMSDU error\n"));
  482. return ;
  483. }
  484. /* set the lastBDPtr */
  485. pBd = pMsdu->firstBDPtr;
  486. while (pBd->nextBDPtr != NULL)
  487. pBd = pBd->nextBDPtr;
  488. pMsdu->lastBDPtr = pBd;
  489. /* Get the Address of the Data filed in the Msdu */
  490. srcDataPtr = (UINT8 *)memMgr_MsduHdrAddr(pMsdu);
  491. /* Copy the Frame Header */
  492. os_memoryCopy(pDebugTrace->hOs, srcDataPtr, &pDebugTrace->FrameHeader, sizeof(pDebugTrace->FrameHeader));
  493. /* Copy the Trace Data */
  494. os_memoryCopy(pDebugTrace->hOs, srcDataPtr + sizeof(pDebugTrace->FrameHeader), pDebugTrace->debugWords, pDebugTrace->TraceBufferSize);
  495. memMgr_BufLength(pMsdu->firstBDPtr) = AcxMpduLen;
  496. pMsdu->dataLen = AcxMpduLen;
  497. /* send the packet to the OS */
  498. os_receivePacket(pDebugTrace->hOs, pMsdu, (UINT16)pMsdu->dataLen);
  499. }
  500. /****************************************************************************
  501. * debugTrace_BuildFrame()
  502. *****************************************************************************
  503. * DESCRIPTION: Build the Trace Frame to be send to the OS
  504. *
  505. * INPUTS: pDebugTrace - Debug Trace object
  506. * MacAddress - for the Ethernet Header
  507. * RETURNS:
  508. *
  509. *****************************************************************************/
  510. static void debugTrace_BuildFrame(DebugTrace_t *pDebugTrace, UINT8* MacAddress)
  511. {
  512. TraceFrame *Frame = &pDebugTrace->FrameHeader;
  513. UINT32 i;
  514. UINT16 local_csum = 0;
  515. UINT16 *pShortData = (UINT16 *)&Frame->IP_Header;
  516. /*
  517. * Calculate each Frame Length
  518. */
  519. /* UDP length should Be !024 of Trace Buffet Size + 8 Byte of UDP header 1032) */
  520. Frame->UDP_Header.UDP_len = wlan_htons(pDebugTrace->TraceBufferSize + sizeof(Frame->UDP_Header));
  521. /* IP length should Be UDP length + IP header */
  522. Frame->IP_Header.Totallen = wlan_htons(wlan_htons(Frame->UDP_Header.UDP_len) + sizeof(Frame->IP_Header));
  523. /*
  524. * initialize the Ethernet Header
  525. */
  526. os_memoryCopy(pDebugTrace->hOs, (UINT8 *)Frame->Ether_Header.ether_dst,
  527. MacAddress, 6);
  528. Frame->Ether_Header.ether_Type = wlan_htons (Ether_Type);
  529. /*
  530. * initialize the IP Header
  531. */
  532. Frame->IP_Header.IpVer = IP_Version;
  533. Frame->IP_Header.TimeToLive = IP_TimeToLive;
  534. Frame->IP_Header.protocol = IP_Protocol;
  535. /* Set the Local host IP */
  536. Frame->IP_Header.dst[0] = Frame->IP_Header.src[0] = 127;
  537. Frame->IP_Header.dst[1] = Frame->IP_Header.src[1] = 0 ;
  538. Frame->IP_Header.dst[2] = Frame->IP_Header.src[2] = 0;
  539. Frame->IP_Header.dst[3] = Frame->IP_Header.src[3] = 1;
  540. /* calculate check sum on words of 16 bits */
  541. for (i=0; i<sizeof(Frame->IP_Header)/2; i++)
  542. local_csum += pShortData[i];
  543. Frame->IP_Header.csum = 0xFFFF - local_csum;
  544. /*
  545. * initialize the UDP Header
  546. */
  547. Frame->UDP_Header.src_port = wlan_htons( Source_Port );
  548. Frame->UDP_Header.dst_port = wlan_htons( Destination_Port );
  549. }
  550. #endif /* !defined(GWSI_DRIVER) && !defined(GWSI_LIB) */
  551. #endif /* TI_DBG */