qdf_trace.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * Copyright (c) 2014-2017 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(__QDF_TRACE_H)
  27. #define __QDF_TRACE_H
  28. /**
  29. * DOC: qdf_trace
  30. * QCA driver framework trace APIs
  31. * Trace, logging, and debugging definitions and APIs
  32. */
  33. /* Include Files */
  34. #include <qdf_types.h> /* For QDF_MODULE_ID... */
  35. #include <stdarg.h> /* For va_list... */
  36. #include <qdf_status.h>
  37. #include <qdf_nbuf.h>
  38. #include <i_qdf_types.h>
  39. /* Type declarations */
  40. #define FL(x) "%s: %d: " x, __func__, __LINE__
  41. #define QDF_TRACE_BUFFER_SIZE (512)
  42. #ifdef CONFIG_MCL
  43. #define QDF_DEFAULT_TRACE_LEVEL \
  44. ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR))
  45. #else
  46. #define QDF_DEFAULT_TRACE_LEVEL (1 << QDF_TRACE_LEVEL_INFO)
  47. #endif
  48. /*
  49. * Log levels
  50. */
  51. #define QDF_DEBUG_FUNCTRACE 0x01
  52. #define QDF_DEBUG_LEVEL0 0x02
  53. #define QDF_DEBUG_LEVEL1 0x04
  54. #define QDF_DEBUG_LEVEL2 0x08
  55. #define QDF_DEBUG_LEVEL3 0x10
  56. #define QDF_DEBUG_ERROR 0x20
  57. #define QDF_DEBUG_CFG 0x40
  58. #ifdef CONFIG_MCL
  59. /**
  60. * qdf_set_pidx() - Sets the global qdf_pidx.
  61. * @pidx : Index of print control object assigned to the module
  62. *
  63. */
  64. void qdf_set_pidx(int pidx);
  65. /**
  66. * qdf_get_pidx() - Returns the global qdf_pidx.
  67. *
  68. * Return : Current qdf print index.
  69. */
  70. int qdf_get_pidx(void);
  71. /* By default Data Path module will have all log levels enabled, except debug
  72. * log level. Debug level will be left up to the framework or user space modules
  73. * to be enabled when issue is detected
  74. */
  75. #define QDF_DATA_PATH_TRACE_LEVEL \
  76. ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \
  77. (1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \
  78. (1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \
  79. (1 << QDF_TRACE_LEVEL_INFO_LOW))
  80. /* Preprocessor definitions and constants */
  81. #define ASSERT_BUFFER_SIZE (512)
  82. #define MAX_QDF_TRACE_RECORDS 4000
  83. #define INVALID_QDF_TRACE_ADDR 0xffffffff
  84. #define DEFAULT_QDF_TRACE_DUMP_COUNT 0
  85. #define DUMP_DP_TRACE 0
  86. #define ENABLE_DP_TRACE_LIVE_MODE 1
  87. #define CLEAR_DP_TRACE_BUFFER 2
  88. #ifdef TRACE_RECORD
  89. #define MTRACE(p) p
  90. #define NO_SESSION 0xFF
  91. #else
  92. #define MTRACE(p) { }
  93. #endif
  94. /**
  95. * typedef struct qdf_trace_record_s - keep trace record
  96. * @qtime: qtimer ticks
  97. * @time: user timestamp
  98. * @module: module name
  99. * @code: hold record of code
  100. * @session: hold record of session
  101. * @data: hold data
  102. * @pid: hold pid of the process
  103. */
  104. typedef struct qdf_trace_record_s {
  105. uint64_t qtime;
  106. char time[18];
  107. uint8_t module;
  108. uint8_t code;
  109. uint16_t session;
  110. uint32_t data;
  111. uint32_t pid;
  112. } qdf_trace_record_t, *tp_qdf_trace_record;
  113. /**
  114. * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer
  115. * @head: position of first record
  116. * @tail: position of last record
  117. * @num: count of total record
  118. * @num_since_last_dump: count from last dump
  119. * @enable: config for controlling the trace
  120. * @dump_count: Dump after number of records reach this number
  121. */
  122. typedef struct s_qdf_trace_data {
  123. uint32_t head;
  124. uint32_t tail;
  125. uint32_t num;
  126. uint16_t num_since_last_dump;
  127. uint8_t enable;
  128. uint16_t dump_count;
  129. } t_qdf_trace_data;
  130. #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
  131. /* DP Trace Implementation */
  132. #ifdef FEATURE_DP_TRACE
  133. #define DPTRACE(p) p
  134. #else
  135. #define DPTRACE(p)
  136. #endif
  137. #define MAX_QDF_DP_TRACE_RECORDS 4000
  138. #define QDF_DP_TRACE_RECORD_SIZE 16
  139. #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff
  140. #define QDF_DP_TRACE_VERBOSITY_HIGH 3
  141. #define QDF_DP_TRACE_VERBOSITY_MEDIUM 2
  142. #define QDF_DP_TRACE_VERBOSITY_LOW 1
  143. #define QDF_DP_TRACE_VERBOSITY_DEFAULT 0
  144. /**
  145. * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
  146. * @QDF_DP_TRACE_INVALID - invalid
  147. * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet
  148. * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet
  149. * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet
  150. * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet
  151. * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt
  152. * QDF_DP_TRACE_EVENT_RECORD - record events
  153. * @QDF_DP_TRACE_DEFAULT_VERBOSITY - below this are part of default verbosity
  154. * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout
  155. * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout
  156. * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record
  157. * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record
  158. * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record
  159. * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record
  160. * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record
  161. * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record
  162. * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record
  163. * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity
  164. * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record
  165. * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  166. * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record
  167. * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record
  168. * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record
  169. * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record
  170. * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  171. * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity
  172. * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD
  173. * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD
  174. * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity
  175. */
  176. enum QDF_DP_TRACE_ID {
  177. QDF_DP_TRACE_INVALID,
  178. QDF_DP_TRACE_DROP_PACKET_RECORD,
  179. QDF_DP_TRACE_EAPOL_PACKET_RECORD,
  180. QDF_DP_TRACE_DHCP_PACKET_RECORD,
  181. QDF_DP_TRACE_ARP_PACKET_RECORD,
  182. QDF_DP_TRACE_MGMT_PACKET_RECORD,
  183. QDF_DP_TRACE_EVENT_RECORD,
  184. QDF_DP_TRACE_DEFAULT_VERBOSITY,
  185. QDF_DP_TRACE_HDD_TX_TIMEOUT,
  186. QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
  187. QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
  188. QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
  189. QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
  190. QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
  191. QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
  192. QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
  193. QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
  194. QDF_DP_TRACE_LOW_VERBOSITY,
  195. QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
  196. QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
  197. QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
  198. QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
  199. QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
  200. QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
  201. QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
  202. QDF_DP_TRACE_MED_VERBOSITY,
  203. QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
  204. QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
  205. QDF_DP_TRACE_HIGH_VERBOSITY,
  206. QDF_DP_TRACE_MAX
  207. };
  208. /**
  209. * qdf_proto_dir - direction
  210. * @QDF_TX: TX direction
  211. * @QDF_RX: RX direction
  212. * @QDF_NA: not applicable
  213. */
  214. enum qdf_proto_dir {
  215. QDF_TX,
  216. QDF_RX,
  217. QDF_NA
  218. };
  219. /**
  220. * struct qdf_dp_trace_ptr_buf - pointer record buffer
  221. * @cookie: cookie value
  222. * @msdu_id: msdu_id
  223. * @status: completion status
  224. */
  225. struct qdf_dp_trace_ptr_buf {
  226. uint64_t cookie;
  227. uint16_t msdu_id;
  228. uint16_t status;
  229. };
  230. /**
  231. * struct qdf_dp_trace_proto_buf - proto packet buffer
  232. * @sa: source address
  233. * @da: destination address
  234. * @vdev_id : vdev id
  235. * @type: packet type
  236. * @subtype: packet subtype
  237. * @dir: direction
  238. */
  239. struct qdf_dp_trace_proto_buf {
  240. struct qdf_mac_addr sa;
  241. struct qdf_mac_addr da;
  242. uint8_t vdev_id;
  243. uint8_t type;
  244. uint8_t subtype;
  245. uint8_t dir;
  246. };
  247. /**
  248. * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
  249. * @vdev_id : vdev id
  250. * @type: packet type
  251. * @subtype: packet subtype
  252. */
  253. struct qdf_dp_trace_mgmt_buf {
  254. uint8_t vdev_id;
  255. uint8_t type;
  256. uint8_t subtype;
  257. };
  258. /**
  259. * struct qdf_dp_trace_event_buf - event buffer
  260. * @vdev_id : vdev id
  261. * @type: packet type
  262. * @subtype: packet subtype
  263. */
  264. struct qdf_dp_trace_event_buf {
  265. uint8_t vdev_id;
  266. uint8_t type;
  267. uint8_t subtype;
  268. };
  269. /**
  270. * struct qdf_dp_trace_record_s - Describes a record in DP trace
  271. * @time: time when it got stored
  272. * @code: Describes the particular event
  273. * @data: buffer to store data
  274. * @size: Length of the valid data stored in this record
  275. * @pid : process id which stored the data in this record
  276. */
  277. struct qdf_dp_trace_record_s {
  278. char time[20];
  279. uint8_t code;
  280. uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
  281. uint8_t size;
  282. uint32_t pid;
  283. };
  284. /**
  285. * struct qdf_dp_trace_data - Parameters to configure/control DP trace
  286. * @head: Position of first record
  287. * @tail: Position of last record
  288. * @num: Current index
  289. * @proto_bitmap: defines which protocol to be traced
  290. * @no_of_record: defines every nth packet to be traced
  291. * @verbosity : defines verbosity level
  292. * @enable: enable/disable DP trace
  293. * @count: current packet number
  294. */
  295. struct s_qdf_dp_trace_data {
  296. uint32_t head;
  297. uint32_t tail;
  298. uint32_t num;
  299. uint8_t proto_bitmap;
  300. uint8_t no_of_record;
  301. uint8_t verbosity;
  302. bool enable;
  303. uint32_t tx_count;
  304. uint32_t rx_count;
  305. bool live_mode;
  306. };
  307. /* Function declarations and documenation */
  308. /**
  309. * qdf_trace_set_level() - Set the trace level for a particular module
  310. * @level : trace level
  311. *
  312. * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating
  313. * the severity of the condition causing the trace message to be issued.
  314. * More severe conditions are more likely to be logged.
  315. *
  316. * This is an external API that allows trace levels to be set for each module.
  317. *
  318. * Return: nothing
  319. */
  320. void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  321. /**
  322. * qdf_trace_get_level() - get the trace level
  323. * @level : trace level
  324. *
  325. * This is an external API that returns a bool value to signify if a
  326. * particular trace level is set for the specified module.
  327. * A member of the QDF_TRACE_LEVEL enumeration indicating the severity
  328. * of the condition causing the trace message to be issued.
  329. *
  330. * Note that individual trace levels are the only valid values
  331. * for this API. QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL
  332. * are not valid input and will return false
  333. *
  334. * Return:
  335. * false - the specified trace level for the specified module is OFF
  336. * true - the specified trace level for the specified module is ON
  337. */
  338. bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  339. typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
  340. typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
  341. void qdf_register_debugcb_init(void);
  342. void qdf_register_debug_callback(QDF_MODULE_ID module_id,
  343. tp_qdf_state_info_cb qdf_state_infocb);
  344. QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
  345. uint16_t *driver_dump_size);
  346. void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data);
  347. void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb);
  348. QDF_STATUS qdf_trace_spin_lock_init(void);
  349. void qdf_trace_init(void);
  350. void qdf_trace_enable(uint32_t, uint8_t enable);
  351. void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
  352. #ifdef FEATURE_DP_TRACE
  353. void qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
  354. enum qdf_proto_dir dir);
  355. void qdf_dp_trace_init(void);
  356. void qdf_dp_trace_spin_lock_init(void);
  357. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  358. uint8_t verbosity);
  359. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
  360. void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  361. uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
  362. void qdf_dp_trace_dump_all(uint32_t count);
  363. typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s* , uint16_t);
  364. void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
  365. uint16_t index);
  366. void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  367. uint8_t *data, uint8_t size, uint16_t msdu_id, uint16_t status);
  368. void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *pRecord,
  369. uint16_t recIndex);
  370. uint8_t qdf_dp_get_proto_bitmap(void);
  371. void
  372. qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  373. uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
  374. enum qdf_proto_subtype subtype, enum qdf_proto_dir dir);
  375. void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
  376. uint16_t index);
  377. void qdf_dp_trace_enable_live_mode(void);
  378. void qdf_dp_trace_clear_buffer(void);
  379. void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  380. enum qdf_proto_type type, enum qdf_proto_subtype subtype);
  381. void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
  382. uint16_t index);
  383. void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
  384. uint16_t index);
  385. void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  386. enum qdf_proto_type type, enum qdf_proto_subtype subtype);
  387. #else
  388. static inline
  389. void qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
  390. enum qdf_proto_dir dir)
  391. {
  392. }
  393. static inline
  394. void qdf_dp_trace_init(void)
  395. {
  396. }
  397. static inline
  398. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
  399. {
  400. }
  401. static inline
  402. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  403. uint8_t verbosity)
  404. {
  405. }
  406. static inline
  407. void qdf_dp_trace_dump_all(uint32_t count)
  408. {
  409. }
  410. static inline
  411. void qdf_dp_trace_enable_live_mode(void)
  412. {
  413. }
  414. static inline
  415. void qdf_dp_trace_clear_buffer(void)
  416. {
  417. }
  418. #endif
  419. void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  420. void *data, int buf_len);
  421. void qdf_trace_display(void);
  422. void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  423. uint8_t on);
  424. void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level);
  425. void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
  426. char *str_format, ...);
  427. #define QDF_SNPRINTF qdf_snprintf
  428. #else
  429. #define DPTRACE(x)
  430. #define qdf_trace_hex_dump(x, y, z, q)
  431. #endif /* CONFIG_MCL */
  432. #define ERROR_CODE -1
  433. #define QDF_MAX_NAME_SIZE 32
  434. #define MAX_PRINT_CONFIG_SUPPORTED 32
  435. #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
  436. /*
  437. * Shared print control index
  438. * for converged debug framework
  439. */
  440. #define QDF_PRINT_IDX_SHARED -1
  441. /**
  442. * QDF_PRINT_INFO() - Generic wrapper API for logging
  443. * @idx : Index of print control object
  444. * @module : Module identifier. A member of QDF_MODULE_ID enumeration that
  445. * identifies the module issuing the trace message
  446. * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
  447. * the severity of the condition causing the trace message to be
  448. * issued.
  449. * @str_format : Format string that contains the message to be logged.
  450. *
  451. *
  452. * This wrapper will be used for any generic logging messages. Wrapper will
  453. * compile a call to converged QDF trace message API.
  454. *
  455. * Return : Nothing
  456. *
  457. */
  458. void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
  459. QDF_TRACE_LEVEL level,
  460. char *str_format, ...);
  461. /**
  462. * struct category_info : Category information structure
  463. * @category_verbose_mask: Embeds information about category's verbose level
  464. */
  465. struct category_info {
  466. uint16_t category_verbose_mask;
  467. };
  468. /**
  469. * struct category_name_info : Category name information structure
  470. * @category_name_str: Embeds information about category name
  471. */
  472. struct category_name_info {
  473. unsigned char category_name_str[QDF_MAX_NAME_SIZE];
  474. };
  475. /**
  476. * qdf_trace_msg_cmn()- Converged logging API
  477. * @idx: Index of print control object assigned to the module
  478. * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
  479. * that identifies the category issuing the trace message.
  480. * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
  481. * indicating the severity of the condition causing the trace
  482. * message to be issued. More severe conditions are more likely
  483. * to be logged.
  484. * @str_format: Format string. The message to be logged. This format string
  485. * contains printf-like replacement parameters, which follow this
  486. * parameter in the variable argument list.
  487. * @val: Variable argument list part of the log message
  488. *
  489. * Return: nothing
  490. *
  491. */
  492. void qdf_trace_msg_cmn(unsigned int idx,
  493. QDF_MODULE_ID category,
  494. QDF_TRACE_LEVEL verbose,
  495. const char *str_format,
  496. va_list val);
  497. /**
  498. * struct qdf_print_ctrl: QDF Print Control structure
  499. * Statically allocated objects of print control
  500. * structure are declared that will support maximum of
  501. * 32 print control objects. Any module that needs to
  502. * register to the print control framework needs to
  503. * obtain a print control object using
  504. * qdf_print_ctrl_register API. It will have to pass
  505. * pointer to category info structure, name and
  506. * custom print function to be used if required.
  507. * @name : Optional name for the control object
  508. * @cat_info : Array of category_info struct
  509. * @custom_print : Custom print handler
  510. * @custom_ctxt : Custom print context
  511. * @dbglvlmac_on : Flag to enable/disable MAC level filtering
  512. * @in_use : Boolean to indicate if control object is in use
  513. */
  514. struct qdf_print_ctrl {
  515. char name[QDF_MAX_NAME_SIZE];
  516. struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
  517. void (*custom_print)(void *ctxt, const char *fmt, va_list args);
  518. void *custom_ctxt;
  519. #ifdef DBG_LVL_MAC_FILTERING
  520. unsigned char dbglvlmac_on;
  521. #endif
  522. bool in_use;
  523. };
  524. /**
  525. * qdf_print_ctrl_register() - Allocate QDF print control object, assign
  526. * pointer to category info or print control
  527. * structure and return the index to the callee
  528. * @cinfo : Pointer to array of category info structure
  529. * @custom_print_handler : Pointer to custom print handler
  530. * @custom_ctx : Pointer to custom context
  531. * @pctrl_name : Pointer to print control object name
  532. *
  533. * Return : Index of qdf_print_ctrl structure
  534. *
  535. */
  536. int qdf_print_ctrl_register(const struct category_info *cinfo,
  537. void *custom_print_handler,
  538. void *custom_ctx,
  539. const char *pctrl_name);
  540. /**
  541. * qdf_print_setup() - Setup default values to all the print control objects
  542. *
  543. * Register new print control object for the callee
  544. *
  545. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
  546. * on failure
  547. */
  548. QDF_STATUS qdf_print_setup(void);
  549. /**
  550. * qdf_print_ctrl_cleanup() - Clean up a print control object
  551. *
  552. * Cleanup the print control object for the callee
  553. *
  554. * @pctrl : Index of print control object
  555. *
  556. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
  557. */
  558. QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
  559. /**
  560. * qdf_print_set_category_verbose() - Enable/Disable category for a
  561. * print control object with
  562. * user provided verbose level
  563. *
  564. * @idx : Index of the print control object assigned to callee
  565. * @category : Category information
  566. * @verbose: Verbose information
  567. * @is_set: Flag indicating if verbose level needs to be enabled or disabled
  568. *
  569. * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  570. */
  571. QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
  572. QDF_MODULE_ID category,
  573. QDF_TRACE_LEVEL verbose,
  574. bool is_set);
  575. /**
  576. * qdf_print_is_category_enabled() - Get category information for the
  577. * print control object
  578. *
  579. * @idx : Index of print control object
  580. * @category : Category information
  581. *
  582. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  583. */
  584. bool qdf_print_is_category_enabled(unsigned int idx,
  585. QDF_MODULE_ID category);
  586. /**
  587. * qdf_print_is_verbose_enabled() - Get verbose information of a category for
  588. * the print control object
  589. *
  590. * @idx : Index of print control object
  591. * @category : Category information
  592. * @verbose : Verbose information
  593. *
  594. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  595. */
  596. bool qdf_print_is_verbose_enabled(unsigned int idx,
  597. QDF_MODULE_ID category,
  598. QDF_TRACE_LEVEL verbose);
  599. /**
  600. * qdf_print_clean_node_flag() - Clean up node flag for print control object
  601. *
  602. * @idx : Index of print control object
  603. *
  604. * Return : None
  605. */
  606. void qdf_print_clean_node_flag(unsigned int idx);
  607. #ifdef DBG_LVL_MAC_FILTERING
  608. /**
  609. * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
  610. *
  611. * @idx : Index of print control object
  612. * @enable : Enable/Disable bit sent by callee
  613. *
  614. * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
  615. */
  616. QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
  617. uint8_t enable);
  618. /**
  619. * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
  620. *
  621. * @idx : Index of print control object
  622. *
  623. * Return : Flag that indicates enable(1) or disable(0) or invalid(-1)
  624. */
  625. bool qdf_print_get_node_flag(unsigned int idx);
  626. #endif
  627. #endif /* __QDF_TRACE_H */