qdf_trace.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #if !defined(__CDF_TRACE_H)
  27. #define __CDF_TRACE_H
  28. /**
  29. * DOC: cdf_trace
  30. *
  31. * Connectivity driver framework trace APIs
  32. *
  33. * Trace, logging, and debugging definitions and APIs
  34. *
  35. */
  36. /* Include Files */
  37. #include <cdf_types.h> /* For CDF_MODULE_ID... */
  38. #include <stdarg.h> /* For va_list... */
  39. #include <cdf_status.h>
  40. #include <cdf_nbuf.h>
  41. #include <cds_packet.h>
  42. #include <i_cdf_types.h>
  43. /* Type declarations */
  44. typedef enum {
  45. /* NONE means NO traces will be logged. This value is in place
  46. * for the cdf_trace_setlevel() to allow the user to turn off
  47. * all traces
  48. */
  49. CDF_TRACE_LEVEL_NONE = 0,
  50. /* Following trace levels are the ones that 'callers' of CDF_TRACE()
  51. * can specify in for the CDF_TRACE_LEVEL parameter. Traces are
  52. * classified by severity. FATAL being more serious than INFO for
  53. * example
  54. */
  55. CDF_TRACE_LEVEL_FATAL,
  56. CDF_TRACE_LEVEL_ERROR,
  57. CDF_TRACE_LEVEL_WARN,
  58. CDF_TRACE_LEVEL_INFO,
  59. CDF_TRACE_LEVEL_INFO_HIGH,
  60. CDF_TRACE_LEVEL_INFO_MED,
  61. CDF_TRACE_LEVEL_INFO_LOW,
  62. CDF_TRACE_LEVEL_DEBUG,
  63. /* All means all trace levels will be active. This value is in place
  64. * for the cdf_trace_setlevel() to allow the user to turn ON all traces
  65. */
  66. CDF_TRACE_LEVEL_ALL,
  67. /* Not a real level. Used to identify the maximum number of
  68. * CDF_TRACE_LEVELs defined
  69. */
  70. CDF_TRACE_LEVEL_MAX
  71. } CDF_TRACE_LEVEL;
  72. /* By default Data Path module will have all log levels enabled, except debug
  73. * log level. Debug level will be left up to the framework or user space modules
  74. * to be enabled when issue is detected
  75. */
  76. #define CDF_DATA_PATH_TRACE_LEVEL \
  77. ((1 << CDF_TRACE_LEVEL_FATAL) | (1 << CDF_TRACE_LEVEL_ERROR) | \
  78. (1 << CDF_TRACE_LEVEL_WARN) | (1 << CDF_TRACE_LEVEL_INFO) | \
  79. (1 << CDF_TRACE_LEVEL_INFO_HIGH) | (1 << CDF_TRACE_LEVEL_INFO_MED) | \
  80. (1 << CDF_TRACE_LEVEL_INFO_LOW))
  81. /* Preprocessor definitions and constants */
  82. #define ASSERT_BUFFER_SIZE (512)
  83. #define CDF_ENABLE_TRACING
  84. #define MAX_CDF_TRACE_RECORDS 4000
  85. #define INVALID_CDF_TRACE_ADDR 0xffffffff
  86. #define DEFAULT_CDF_TRACE_DUMP_COUNT 0
  87. #include <i_cdf_trace.h>
  88. #ifdef TRACE_RECORD
  89. #define MTRACE(p) p
  90. #define NO_SESSION 0xFF
  91. #else
  92. #define MTRACE(p) { }
  93. #endif
  94. /* Structure definition */
  95. typedef struct cdf_trace_record_s {
  96. uint64_t time;
  97. uint8_t module;
  98. uint8_t code;
  99. uint16_t session;
  100. uint32_t data;
  101. uint32_t pid;
  102. } cdf_trace_record_t, *tp_cdf_trace_record;
  103. typedef struct s_cdf_trace_data {
  104. /* MTRACE logs are stored in ring buffer where head represents the
  105. * position of first record, tail represents the position of last record
  106. * added till now and num is the count of total record added
  107. */
  108. uint32_t head;
  109. uint32_t tail;
  110. uint32_t num;
  111. uint16_t numSinceLastDump;
  112. /* config for controlling the trace */
  113. uint8_t enable;
  114. /* Dump after number of records reach this number */
  115. uint16_t dumpCount;
  116. } t_cdf_trace_data;
  117. #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
  118. /* DP Trace Implementation */
  119. #define DPTRACE(p) p
  120. #define MAX_CDF_DP_TRACE_RECORDS 4000
  121. #define CDF_DP_TRACE_RECORD_SIZE 16
  122. #define INVALID_CDF_DP_TRACE_ADDR 0xffffffff
  123. #define CDF_DP_TRACE_VERBOSITY_HIGH 3
  124. #define CDF_DP_TRACE_VERBOSITY_MEDIUM 2
  125. #define CDF_DP_TRACE_VERBOSITY_LOW 1
  126. #define CDF_DP_TRACE_VERBOSITY_DEFAULT 0
  127. /**
  128. * enum CDF_DP_TRACE_ID - Generic ID to identify various events in data path
  129. * @CDF_DP_TRACE_INVALID: Invalid ID
  130. * @CDF_DP_TRACE_DROP_PACKET_RECORD: Dropped packet stored with this id
  131. * @CDF_DP_TRACE_HDD_PACKET_PTR_RECORD: nbuf->data ptr of HDD
  132. * @CDF_DP_TRACE_HDD_PACKET_RECORD: nbuf->data stored with this id
  133. * @CDF_DP_TRACE_CE_PACKET_PTR_RECORD: nbuf->data ptr of CE
  134. * @CDF_DP_TRACE_CE_PACKET_RECORD: nbuf->data stored with this id
  135. * @CDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD: nbuf->data ptr of txrx queue
  136. * @CDF_DP_TRACE_TXRX_PACKET_PTR_RECORD: nbuf->data ptr of txrx
  137. * @CDF_DP_TRACE_HTT_PACKET_PTR_RECORD: nbuf->data ptr of htt
  138. * @CDF_DP_TRACE_HTC_PACKET_PTR_RECORD: nbuf->data ptr of htc
  139. * @CDF_DP_TRACE_HIF_PACKET_PTR_RECORD: nbuf->data ptr of hif
  140. * @CDF_DP_TRACE_HDD_TX_TIMEOUT: hdd tx timeout event
  141. * @CDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: hdd tx softap timeout event
  142. * @CDF_DP_TRACE_VDEV_PAUSE: vdev pause event
  143. * @CDF_DP_TRACE_VDEV_UNPAUSE: vdev unpause event
  144. *
  145. */
  146. enum CDF_DP_TRACE_ID {
  147. CDF_DP_TRACE_INVALID = 0,
  148. CDF_DP_TRACE_DROP_PACKET_RECORD = 1,
  149. CDF_DP_TRACE_HDD_PACKET_PTR_RECORD = 2,
  150. CDF_DP_TRACE_HDD_PACKET_RECORD = 3,
  151. CDF_DP_TRACE_CE_PACKET_PTR_RECORD = 4,
  152. CDF_DP_TRACE_CE_PACKET_RECORD = 5,
  153. CDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD = 6,
  154. CDF_DP_TRACE_TXRX_PACKET_PTR_RECORD = 7,
  155. CDF_DP_TRACE_HTT_PACKET_PTR_RECORD = 8,
  156. CDF_DP_TRACE_HTC_PACKET_PTR_RECORD = 9,
  157. CDF_DP_TRACE_HIF_PACKET_PTR_RECORD = 10,
  158. CDF_DP_TRACE_HDD_TX_TIMEOUT = 11,
  159. CDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT = 12,
  160. CDF_DP_TRACE_VDEV_PAUSE = 13,
  161. CDF_DP_TRACE_VDEV_UNPAUSE = 14,
  162. CDF_DP_TRACE_MAX
  163. };
  164. /**
  165. * struct cdf_dp_trace_record_s - Describes a record in DP trace
  166. * @time: time when it got stored
  167. * @code: Describes the particular event
  168. * @data: buffer to store data
  169. * @size: Length of the valid data stored in this record
  170. * @pid : process id which stored the data in this record
  171. */
  172. struct cdf_dp_trace_record_s {
  173. uint64_t time;
  174. uint8_t code;
  175. uint8_t data[CDF_DP_TRACE_RECORD_SIZE];
  176. uint8_t size;
  177. uint32_t pid;
  178. };
  179. /**
  180. * struct cdf_dp_trace_data - Parameters to configure/control DP trace
  181. * @head: Position of first record
  182. * @tail: Position of last record
  183. * @num: Current index
  184. * @proto_bitmap: defines which protocol to be traced
  185. * @no_of_record: defines every nth packet to be traced
  186. * @verbosity : defines verbosity level
  187. * @enable: enable/disable DP trace
  188. * @count: current packet number
  189. */
  190. struct s_cdf_dp_trace_data {
  191. uint32_t head;
  192. uint32_t tail;
  193. uint32_t num;
  194. /* config for controlling the trace */
  195. uint8_t proto_bitmap;
  196. uint8_t no_of_record;
  197. uint8_t verbosity;
  198. bool enable;
  199. uint32_t count;
  200. };
  201. /* Function declarations and documenation */
  202. /**
  203. * cdf_trace_set_level() - Set the trace level for a particular module
  204. * @level : trace level
  205. *
  206. * Trace level is a member of the CDF_TRACE_LEVEL enumeration indicating
  207. * the severity of the condition causing the trace message to be issued.
  208. * More severe conditions are more likely to be logged.
  209. *
  210. * This is an external API that allows trace levels to be set for each module.
  211. *
  212. * Return: nothing
  213. */
  214. void cdf_trace_set_level(CDF_MODULE_ID module, CDF_TRACE_LEVEL level);
  215. /**
  216. * cdf_trace_get_level() - get the trace level
  217. * @level : trace level
  218. *
  219. * This is an external API that returns a bool value to signify if a
  220. * particular trace level is set for the specified module.
  221. * A member of the CDF_TRACE_LEVEL enumeration indicating the severity
  222. * of the condition causing the trace message to be issued.
  223. *
  224. * Note that individual trace levels are the only valid values
  225. * for this API. CDF_TRACE_LEVEL_NONE and CDF_TRACE_LEVEL_ALL
  226. * are not valid input and will return false
  227. *
  228. * Return:
  229. * false - the specified trace level for the specified module is OFF
  230. * true - the specified trace level for the specified module is ON
  231. */
  232. bool cdf_trace_get_level(CDF_MODULE_ID module, CDF_TRACE_LEVEL level);
  233. typedef void (*tp_cdf_trace_cb)(void *pMac, tp_cdf_trace_record, uint16_t);
  234. void cdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data);
  235. void cdf_trace_register(CDF_MODULE_ID, tp_cdf_trace_cb);
  236. CDF_STATUS cdf_trace_spin_lock_init(void);
  237. void cdf_trace_init(void);
  238. void cdf_trace_enable(uint32_t, uint8_t enable);
  239. void cdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
  240. void cdf_dp_trace_spin_lock_init(void);
  241. void cdf_dp_trace_init(void);
  242. void cdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  243. uint8_t verbosity);
  244. void cdf_dp_trace_set_track(cdf_nbuf_t nbuf);
  245. void cdf_dp_trace(cdf_nbuf_t nbuf, enum CDF_DP_TRACE_ID code,
  246. uint8_t *data, uint8_t size);
  247. void cdf_dp_trace_dump_all(uint32_t count);
  248. typedef void (*tp_cdf_dp_trace_cb)(struct cdf_dp_trace_record_s* , uint16_t);
  249. void cdf_dp_display_record(struct cdf_dp_trace_record_s *record,
  250. uint16_t index);
  251. #endif