dp_htt_logger.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #include <cdp_txrx_handle.h>
  21. #ifndef HTT_EVENT_DEBUG_MAX_ENTRY
  22. #define HTT_EVENT_DEBUG_MAX_ENTRY (1024)
  23. #endif
  24. #define HTT_EVENT_DEBUG_ENTRY_MAX_LENGTH (32)
  25. #define HTT_COMMAND_DEBUG_ENTRY_MAX_LENGTH (32)
  26. #define HTT_WBM_EVENT_DEBUG_ENTRY_MAX_LENGTH (32)
  27. #define NUM_HTT_DEBUG_INFOS 8
  28. #define HTT_LOGD(args ...) \
  29. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_DEBUG, ## args)
  30. #define HTT_LOGI(args ...) \
  31. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_INFO, ## args)
  32. #define HTT_LOGW(args ...) \
  33. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_WARN, ## args)
  34. #define HTT_LOGE(args ...) \
  35. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_ERROR, ## args)
  36. #define HTT_LOGP(args ...) \
  37. QDF_TRACE(QDF_MODULE_ID_HTT, QDF_TRACE_LEVEL_FATAL, ## args)
  38. /**
  39. * struct htt_command_debug - HTT command log buffer data type
  40. * @ command - Store HTT MSG id
  41. * @ data - vdevid,peerid
  42. * @ time - Time of HTT command handling
  43. * @ cpu_id - Cpu number which handles cmd/event
  44. */
  45. struct htt_command_debug {
  46. uint8_t command;
  47. uint8_t data[HTT_COMMAND_DEBUG_ENTRY_MAX_LENGTH];
  48. uint64_t time;
  49. uint8_t cpu_id;
  50. };
  51. /**
  52. * struct htt_event_debug - HTT event log buffer data type
  53. * @ event - Store HTT event id
  54. * @ data - vdevid,peerid
  55. * @ time - Time of HTT event handling
  56. * @ cpu_id - Cpu number which handles cmd/event
  57. */
  58. struct htt_event_debug {
  59. uint8_t event;
  60. uint8_t data[HTT_EVENT_DEBUG_ENTRY_MAX_LENGTH];
  61. uint64_t time;
  62. uint8_t cpu_id;
  63. };
  64. /**
  65. * struct htt_wbm_event_debug - HTT wbm event log buffer data type
  66. * @ tx_status - Status
  67. * @ data - msg data(peer_id,tid..)
  68. * @ time - Time of HTT event handling
  69. * @ cpu_id - Cpu number which handles cmd/event
  70. */
  71. struct htt_wbm_event_debug {
  72. uint8_t tx_status;
  73. uint8_t data[HTT_WBM_EVENT_DEBUG_ENTRY_MAX_LENGTH];
  74. uint64_t time;
  75. uint8_t cpu_id;
  76. };
  77. /**
  78. * struct htt_log_buf_t - HTT log buffer information type
  79. * @buf - Refernce to HTT log buffer
  80. * @ length - total count of command/event logged
  81. * @ buf_tail_idx - Tail index of buffer
  82. * @ size - the size of the buffer in number of entries
  83. * @record_lock - Lock HTT recording separate for all cmd/event/wbm
  84. */
  85. struct htt_log_buf_t {
  86. void *buf;
  87. uint32_t length;
  88. uint32_t buf_tail_idx;
  89. uint32_t size;
  90. qdf_spinlock_t record_lock;
  91. };
  92. /**
  93. * struct htt_debug_log_info - Meta data to hold information of
  94. * all buffers used for HTT logging
  95. * @htt_command_log_buf_info - Buffer info for HTT Command log
  96. * @htt_event_log_buf_info - Buffer info for HTT Event log
  97. * @htt_wbm_event_log_buf_info - Buffer info for HTT wbm event log
  98. * @htt_record_lock - Lock HTT recording (while reading through debugfs)
  99. * @htt_logging_enable - Enable/Disable state for HTT logging
  100. * @htt_cmd_disable_list - Enable/Disable logging for some
  101. * specific cmd(BitMap)
  102. * @htt_event_disable_list - Enable/Disable logging for some
  103. * specific Event(BitMap)
  104. * @htt_wbm_event_disable_list - Enable/Disable logging for
  105. * some specific wbm event(BitMap)
  106. * @stop_seq - Used for read ack.
  107. * stop read sequence once done.
  108. * qdf_debugfs show calls .show function ptr iteratively
  109. * and hence we need to explicitly stop after one call.
  110. * 1 bit is used for one fops show call.
  111. * Default all is set to 0.
  112. * @htt_log_debugfs_dir - refernce to debugfs directory
  113. */
  114. struct htt_debug_log_info {
  115. struct htt_log_buf_t htt_command_log_buf_info;
  116. struct htt_log_buf_t htt_event_log_buf_info;
  117. struct htt_log_buf_t htt_wbm_event_log_buf_info;
  118. qdf_spinlock_t htt_record_lock;
  119. bool htt_logging_enable;
  120. uint64_t htt_cmd_disable_list;
  121. uint64_t htt_event_disable_list;
  122. uint64_t htt_wbm_event_disable_list;
  123. uint16_t stop_seq;
  124. qdf_dentry_t htt_log_debugfs_dir;
  125. };
  126. /**
  127. * @ debugfs_de - Dentry for each debugfs exported entry
  128. * @log_info - Data for all commad/event
  129. */
  130. struct htt_logger {
  131. qdf_dentry_t debugfs_de[NUM_HTT_DEBUG_INFOS];
  132. struct htt_debug_log_info log_info;
  133. };
  134. /**
  135. * htt_interface_logging_init() - Initialize HTT event tracer
  136. *
  137. * @ htt_logger_handle - Pointer for HTT tracer
  138. */
  139. void htt_interface_logging_init(struct htt_logger **htt_logger_handle,
  140. struct cdp_ctrl_objmgr_psoc *ctrl_psoc);
  141. /**
  142. * htt_interface_logging_deinit() - Deinitialize HTT event tracer
  143. *
  144. * @ htt_logger_handle - Pointer for HTT tracer
  145. */
  146. void htt_interface_logging_deinit(struct htt_logger *htt_logger_handle);
  147. /**
  148. * htt_command_recored() - Record HTT command
  149. *
  150. * @ h - Pointer for HTT tracer
  151. * @ msg_type - Message type to be logged
  152. * @ msg_data - Data to be logged
  153. */
  154. int htt_command_record(struct htt_logger *h, uint8_t msg_type,
  155. uint8_t *msg_data);
  156. /**
  157. * htt_event_recored() - Record HTT event
  158. *
  159. * @ h - Pointer for HTT tracer
  160. * @ msg_type - Message type to be logged
  161. * @ msg_data - Data to be logged
  162. */
  163. int htt_event_record(struct htt_logger *h, uint8_t msg_type,
  164. uint8_t *msg_data);
  165. /**
  166. * htt_wbm_event_recored() - Record HTT wbm event
  167. *
  168. * @ h - Pointer for HTT tracer
  169. * @ tx_status - Status flag
  170. * @ msg_data - Data to be logged
  171. */
  172. int htt_wbm_event_record(struct htt_logger *h, uint8_t tx_status,
  173. uint8_t *msg_data);
  174. #endif /* _HTT_EVENT_LOGGING__ */