2
0

mvDebug.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*******************************************************************************
  2. Copyright (C) Marvell International Ltd. and its affiliates
  3. This software file (the "File") is owned and distributed by Marvell
  4. International Ltd. and/or its affiliates ("Marvell") under the following
  5. alternative licensing terms. Once you have made an election to distribute the
  6. File under one of the following license alternatives, please (i) delete this
  7. introductory statement regarding license alternatives, (ii) delete the two
  8. license alternatives that you have not elected to use and (iii) preserve the
  9. Marvell copyright notice above.
  10. ********************************************************************************
  11. Marvell Commercial License Option
  12. If you received this File from Marvell and you have entered into a commercial
  13. license agreement (a "Commercial License") with Marvell, the File is licensed
  14. to you under the terms of the applicable Commercial License.
  15. ********************************************************************************
  16. Marvell GPL License Option
  17. If you received this File from Marvell, you may opt to use, redistribute and/or
  18. modify this File in accordance with the terms and conditions of the General
  19. Public License Version 2, June 1991 (the "GPL License"), a copy of which is
  20. available along with the File in the license.txt file or by writing to the Free
  21. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
  22. on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
  23. THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
  24. WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
  25. DISCLAIMED. The GPL License provides additional details about this warranty
  26. disclaimer.
  27. ********************************************************************************
  28. Marvell BSD License Option
  29. If you received this File from Marvell, you may opt to use, redistribute and/or
  30. modify this File under the following licensing terms.
  31. Redistribution and use in source and binary forms, with or without modification,
  32. are permitted provided that the following conditions are met:
  33. * Redistributions of source code must retain the above copyright notice,
  34. this list of conditions and the following disclaimer.
  35. * Redistributions in binary form must reproduce the above copyright
  36. notice, this list of conditions and the following disclaimer in the
  37. documentation and/or other materials provided with the distribution.
  38. * Neither the name of Marvell nor the names of its contributors may be
  39. used to endorse or promote products derived from this software without
  40. specific prior written permission.
  41. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  42. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  43. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  44. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  45. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  46. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  47. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  48. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  49. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  50. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  51. *******************************************************************************/
  52. #ifndef __INCmvDebugh
  53. #define __INCmvDebugh
  54. /* includes */
  55. #include "mvTypes.h"
  56. typedef enum
  57. {
  58. MV_MODULE_INVALID = -1,
  59. MV_MODULE_ETH = 0,
  60. MV_MODULE_IDMA,
  61. MV_MODULE_XOR,
  62. MV_MODULE_TWASI,
  63. MV_MODULE_MGI,
  64. MV_MODULE_USB,
  65. MV_MODULE_CESA,
  66. MV_MODULE_MAX
  67. }MV_MODULE_ID;
  68. /* Define generic flags useful for most of modules */
  69. #define MV_DEBUG_FLAG_ALL (0)
  70. #define MV_DEBUG_FLAG_INIT (1 << 0)
  71. #define MV_DEBUG_FLAG_RX (1 << 1)
  72. #define MV_DEBUG_FLAG_TX (1 << 2)
  73. #define MV_DEBUG_FLAG_ERR (1 << 3)
  74. #define MV_DEBUG_FLAG_TRACE (1 << 4)
  75. #define MV_DEBUG_FLAG_DUMP (1 << 5)
  76. #define MV_DEBUG_FLAG_CACHE (1 << 6)
  77. #define MV_DEBUG_FLAG_IOCTL (1 << 7)
  78. #define MV_DEBUG_FLAG_STATS (1 << 8)
  79. extern MV_U32 mvDebug;
  80. extern MV_U32 mvDebugModules[MV_MODULE_MAX];
  81. #ifdef MV_DEBUG
  82. # define MV_DEBUG_PRINT(module, flags, msg) mvOsPrintf msg
  83. # define MV_DEBUG_CODE(module, flags, code) code
  84. #elif defined(MV_RT_DEBUG)
  85. # define MV_DEBUG_PRINT(module, flags, msg) \
  86. if( (mvDebug & (1<<(module))) && \
  87. ((mvDebugModules[(module)] & (flags)) == (flags)) ) \
  88. mvOsPrintf msg
  89. # define MV_DEBUG_CODE(module, flags, code) \
  90. if( (mvDebug & (1<<(module))) && \
  91. ((mvDebugModules[(module)] & (flags)) == (flags)) ) \
  92. code
  93. #else
  94. # define MV_DEBUG_PRINT(module, flags, msg)
  95. # define MV_DEBUG_CODE(module, flags, code)
  96. #endif
  97. /* typedefs */
  98. /* time measurement structure used to check how much time pass between
  99. * two points
  100. */
  101. typedef struct {
  102. char name[20]; /* name of the entry */
  103. unsigned long begin; /* time measured on begin point */
  104. unsigned long end; /* time measured on end point */
  105. unsigned long total; /* Accumulated time */
  106. unsigned long left; /* The rest measurement actions */
  107. unsigned long count; /* Maximum measurement actions */
  108. unsigned long min; /* Minimum time from begin to end */
  109. unsigned long max; /* Maximum time from begin to end */
  110. } MV_DEBUG_TIMES;
  111. /* mvDebug.h API list */
  112. /****** Error Recording ******/
  113. /* Dump memory in specific format:
  114. * address: X1X1X1X1 X2X2X2X2 ... X8X8X8X8
  115. */
  116. void mvDebugMemDump(void* addr, int size, int access);
  117. void mvDebugPrintBufInfo(BUF_INFO* pBufInfo, int size, int access);
  118. void mvDebugPrintPktInfo(MV_PKT_INFO* pPktInfo, int size, int access);
  119. void mvDebugPrintIpAddr(MV_U32 ipAddr);
  120. void mvDebugPrintMacAddr(const MV_U8* pMacAddr);
  121. /**** There are three functions deals with MV_DEBUG_TIMES structure ****/
  122. /* Reset MV_DEBUG_TIMES entry */
  123. void mvDebugResetTimeEntry(MV_DEBUG_TIMES* pTimeEntry, int count, char* name);
  124. /* Update MV_DEBUG_TIMES entry */
  125. void mvDebugUpdateTimeEntry(MV_DEBUG_TIMES* pTimeEntry);
  126. /* Print out MV_DEBUG_TIMES entry */
  127. void mvDebugPrintTimeEntry(MV_DEBUG_TIMES* pTimeEntry, MV_BOOL isTitle);
  128. /******** General ***********/
  129. /* Change value of mvDebugPrint global variable */
  130. void mvDebugInit(void);
  131. void mvDebugModuleEnable(MV_MODULE_ID module, MV_BOOL isEnable);
  132. void mvDebugModuleSetFlags(MV_MODULE_ID module, MV_U32 flags);
  133. void mvDebugModuleClearFlags(MV_MODULE_ID module, MV_U32 flags);
  134. #endif /* __INCmvDebug.h */