dp_htt_logger.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (c) 2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HTT_EVENT_LOGGING__
  19. #define _HTT_EVENT_LOGGING__
  20. #ifndef HTT_EVENT_DEBUG_MAX_ENTRY
  21. #define HTT_EVENT_DEBUG_MAX_ENTRY (1024)
  22. #endif
  23. #define HTT_EVENT_DEBUG_ENTRY_MAX_LENGTH (32)
  24. #define HTT_COMMAND_DEBUG_ENTRY_MAX_LENGTH (32)
  25. #define HTT_WBM_EVENT_DEBUG_ENTRY_MAX_LENGTH (32)
  26. #define NUM_HTT_DEBUG_INFOS 8
  27. #define HTT_LOGD(args ...) \
  28. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_DEBUG, ## args)
  29. #define HTT_LOGI(args ...) \
  30. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_INFO, ## args)
  31. #define HTT_LOGW(args ...) \
  32. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_WARN, ## args)
  33. #define HTT_LOGE(args ...) \
  34. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_ERROR, ## args)
  35. #define HTT_LOGP(args ...) \
  36. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_FATAL, ## args)
  37. /**
  38. * struct htt_command_debug - HTT command log buffer data type
  39. * @ command - Store HTT MSG id
  40. * @ data - vdevid,peerid
  41. * @ time - Time of HTT command handling
  42. * @ cpu_id - Cpu number which handles cmd/event
  43. */
  44. struct htt_command_debug {
  45. uint8_t command;
  46. uint8_t data[HTT_COMMAND_DEBUG_ENTRY_MAX_LENGTH];
  47. uint64_t time;
  48. uint8_t cpu_id;
  49. };
  50. /**
  51. * struct htt_event_debug - HTT event log buffer data type
  52. * @ event - Store HTT event id
  53. * @ data - vdevid,peerid
  54. * @ time - Time of HTT event handling
  55. * @ cpu_id - Cpu number which handles cmd/event
  56. */
  57. struct htt_event_debug {
  58. uint8_t event;
  59. uint8_t data[HTT_EVENT_DEBUG_ENTRY_MAX_LENGTH];
  60. uint64_t time;
  61. uint8_t cpu_id;
  62. };
  63. /**
  64. * struct htt_wbm_event_debug - HTT wbm event log buffer data type
  65. * @ tx_status - Status
  66. * @ data - msg data(peer_id,tid..)
  67. * @ time - Time of HTT event handling
  68. * @ cpu_id - Cpu number which handles cmd/event
  69. */
  70. struct htt_wbm_event_debug {
  71. uint8_t tx_status;
  72. uint8_t data[HTT_WBM_EVENT_DEBUG_ENTRY_MAX_LENGTH];
  73. uint64_t time;
  74. uint8_t cpu_id;
  75. };
  76. /**
  77. * struct htt_log_buf_t - HTT log buffer information type
  78. * @buf - Refernce to HTT log buffer
  79. * @ length - total count of command/event logged
  80. * @ buf_tail_idx - Tail index of buffer
  81. * @ size - the size of the buffer in number of entries
  82. * @record_lock - Lock HTT recording separate for all cmd/event/wbm
  83. */
  84. struct htt_log_buf_t {
  85. void *buf;
  86. uint32_t length;
  87. uint32_t buf_tail_idx;
  88. uint32_t size;
  89. qdf_spinlock_t record_lock;
  90. };
  91. /**
  92. * struct htt_debug_log_info - Meta data to hold information of
  93. * all buffers used for HTT logging
  94. * @htt_command_log_buf_info - Buffer info for HTT Command log
  95. * @htt_event_log_buf_info - Buffer info for HTT Event log
  96. * @htt_wbm_event_log_buf_info - Buffer info for HTT wbm event log
  97. * @htt_record_lock - Lock HTT recording (while reading through debugfs)
  98. * @htt_logging_enable - Enable/Disable state for HTT logging
  99. * @htt_cmd_disable_list - Enable/Disable logging for some
  100. * specific cmd(BitMap)
  101. * @htt_event_disable_list - Enable/Disable logging for some
  102. * specific Event(BitMap)
  103. * @htt_wbm_event_disable_list - Enable/Disable logging for
  104. * some specific wbm event(BitMap)
  105. * @stop_seq - Used for read ack.
  106. * stop read sequence once done.
  107. * qdf_debugfs show calls .show function ptr iteratively
  108. * and hence we need to explicitly stop after one call.
  109. * 1 bit is used for one fops show call.
  110. * Default all is set to 0.
  111. * @htt_log_debugfs_dir - refernce to debugfs directory
  112. */
  113. struct htt_debug_log_info {
  114. struct htt_log_buf_t htt_command_log_buf_info;
  115. struct htt_log_buf_t htt_event_log_buf_info;
  116. struct htt_log_buf_t htt_wbm_event_log_buf_info;
  117. qdf_spinlock_t htt_record_lock;
  118. bool htt_logging_enable;
  119. uint64_t htt_cmd_disable_list;
  120. uint64_t htt_event_disable_list;
  121. uint64_t htt_wbm_event_disable_list;
  122. uint16_t stop_seq;
  123. qdf_dentry_t htt_log_debugfs_dir;
  124. };
  125. /**
  126. * @ debugfs_de - Dentry for each debugfs exported entry
  127. * @log_info - Data for all commad/event
  128. */
  129. struct htt_logger {
  130. qdf_dentry_t debugfs_de[NUM_HTT_DEBUG_INFOS];
  131. struct htt_debug_log_info log_info;
  132. };
  133. /**
  134. * htt_interface_logging_init() - Initialize HTT event tracer
  135. *
  136. * @ htt_logger_handle - Pointer for HTT tracer
  137. */
  138. void htt_interface_logging_init(struct htt_logger **htt_logger_handle);
  139. /**
  140. * htt_interface_logging_deinit() - Deinitialize HTT event tracer
  141. *
  142. * @ htt_logger_handle - Pointer for HTT tracer
  143. */
  144. void htt_interface_logging_deinit(struct htt_logger *htt_logger_handle);
  145. /**
  146. * htt_command_recored() - Record HTT command
  147. *
  148. * @ h - Pointer for HTT tracer
  149. * @ msg_type - Message type to be logged
  150. * @ msg_data - Data to be logged
  151. */
  152. int htt_command_record(struct htt_logger *h, uint8_t msg_type,
  153. uint8_t *msg_data);
  154. /**
  155. * htt_event_recored() - Record HTT event
  156. *
  157. * @ h - Pointer for HTT tracer
  158. * @ msg_type - Message type to be logged
  159. * @ msg_data - Data to be logged
  160. */
  161. int htt_event_record(struct htt_logger *h, uint8_t msg_type,
  162. uint8_t *msg_data);
  163. /**
  164. * htt_wbm_event_recored() - Record HTT wbm event
  165. *
  166. * @ h - Pointer for HTT tracer
  167. * @ tx_status - Status flag
  168. * @ msg_data - Data to be logged
  169. */
  170. int htt_wbm_event_record(struct htt_logger *h, uint8_t tx_status,
  171. uint8_t *msg_data);
  172. #endif /* _HTT_EVENT_LOGGING__ */