qdf_trace.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  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. #define QDF_CATEGORY_INFO_U16(val) (((val >> 16) & 0x0000FFFF))
  49. #define QDF_TRACE_LEVEL_INFO_L16(val) (val & 0x0000FFFF)
  50. typedef int (qdf_abstract_print)(void *priv, const char *fmt, ...);
  51. /*
  52. * Log levels
  53. */
  54. #define QDF_DEBUG_FUNCTRACE 0x01
  55. #define QDF_DEBUG_LEVEL0 0x02
  56. #define QDF_DEBUG_LEVEL1 0x04
  57. #define QDF_DEBUG_LEVEL2 0x08
  58. #define QDF_DEBUG_LEVEL3 0x10
  59. #define QDF_DEBUG_ERROR 0x20
  60. #define QDF_DEBUG_CFG 0x40
  61. /* DP Trace Implementation */
  62. #ifdef CONFIG_DP_TRACE
  63. #define DPTRACE(p) p
  64. #else
  65. #define DPTRACE(p)
  66. #endif
  67. #ifdef CONFIG_MCL
  68. void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data);
  69. #endif
  70. /* By default Data Path module will have all log levels enabled, except debug
  71. * log level. Debug level will be left up to the framework or user space modules
  72. * to be enabled when issue is detected
  73. */
  74. #define QDF_DATA_PATH_TRACE_LEVEL \
  75. ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \
  76. (1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \
  77. (1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \
  78. (1 << QDF_TRACE_LEVEL_INFO_LOW))
  79. /* Preprocessor definitions and constants */
  80. #define ASSERT_BUFFER_SIZE (512)
  81. #define QDF_TRACE_DEFAULT_PDEV_ID 0xff
  82. #define MAX_QDF_TRACE_RECORDS 4000
  83. #define INVALID_QDF_TRACE_ADDR 0xffffffff
  84. #define DEFAULT_QDF_TRACE_DUMP_COUNT 0
  85. /*
  86. * first parameter to iwpriv command - dump_dp_trace
  87. * iwpriv wlan0 dump_dp_trace 0 0 -> dump full buffer
  88. * iwpriv wlan0 dump_dp_trace 1 0 -> enable live view mode
  89. * iwpriv wlan0 dump_dp_trace 2 0 -> clear dp trace buffer
  90. * iwpriv wlan0 dump_dp_trace 3 0 -> disable live view mode
  91. */
  92. #define DUMP_DP_TRACE 0
  93. #define ENABLE_DP_TRACE_LIVE_MODE 1
  94. #define CLEAR_DP_TRACE_BUFFER 2
  95. #define DISABLE_DP_TRACE_LIVE_MODE 3
  96. #ifdef TRACE_RECORD
  97. #define MTRACE(p) p
  98. #define NO_SESSION 0xFF
  99. #else
  100. #define MTRACE(p) { }
  101. #endif
  102. /**
  103. * typedef struct qdf_trace_record_s - keep trace record
  104. * @qtime: qtimer ticks
  105. * @time: user timestamp
  106. * @module: module name
  107. * @code: hold record of code
  108. * @session: hold record of session
  109. * @data: hold data
  110. * @pid: hold pid of the process
  111. */
  112. typedef struct qdf_trace_record_s {
  113. uint64_t qtime;
  114. char time[18];
  115. uint8_t module;
  116. uint8_t code;
  117. uint16_t session;
  118. uint32_t data;
  119. uint32_t pid;
  120. } qdf_trace_record_t, *tp_qdf_trace_record;
  121. /**
  122. * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer
  123. * @head: position of first record
  124. * @tail: position of last record
  125. * @num: count of total record
  126. * @num_since_last_dump: count from last dump
  127. * @enable: config for controlling the trace
  128. * @dump_count: Dump after number of records reach this number
  129. */
  130. typedef struct s_qdf_trace_data {
  131. uint32_t head;
  132. uint32_t tail;
  133. uint32_t num;
  134. uint16_t num_since_last_dump;
  135. uint8_t enable;
  136. uint16_t dump_count;
  137. } t_qdf_trace_data;
  138. #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
  139. #define MAX_QDF_DP_TRACE_RECORDS 4000
  140. #define QDF_DP_TRACE_RECORD_SIZE 16
  141. #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff
  142. #define QDF_DP_TRACE_VERBOSITY_HIGH 3
  143. #define QDF_DP_TRACE_VERBOSITY_MEDIUM 2
  144. #define QDF_DP_TRACE_VERBOSITY_LOW 1
  145. #define QDF_DP_TRACE_VERBOSITY_BASE 0
  146. /**
  147. * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
  148. * @QDF_DP_TRACE_INVALID - invalid
  149. * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet
  150. * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet
  151. * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet
  152. * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet
  153. * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt
  154. * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packet
  155. * @QDF_DP_TRACE_ICMPv6_PACKET_RECORD - record ICMPv6 packet
  156. * QDF_DP_TRACE_EVENT_RECORD - record events
  157. * @QDF_DP_TRACE_BASE_VERBOSITY - below this are part of base verbosity
  158. * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packets
  159. * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD
  160. * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD
  161. * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout
  162. * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout
  163. * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record
  164. * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity
  165. * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record
  166. * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record
  167. * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record
  168. * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record
  169. * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record
  170. * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record
  171. * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record
  172. * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record
  173. * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity
  174. * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record
  175. * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  176. * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record
  177. * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record
  178. * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record
  179. * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record
  180. * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  181. * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record 32 bytes of tx pkt at LI_DP
  182. * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record 32 bytes of rx pkt at LI_DP
  183. * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD
  184. * - record 32 bytes of rx null_queue pkt at LI_DP
  185. * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity
  186. */
  187. enum QDF_DP_TRACE_ID {
  188. QDF_DP_TRACE_INVALID,
  189. QDF_DP_TRACE_DROP_PACKET_RECORD,
  190. QDF_DP_TRACE_EAPOL_PACKET_RECORD,
  191. QDF_DP_TRACE_DHCP_PACKET_RECORD,
  192. QDF_DP_TRACE_ARP_PACKET_RECORD,
  193. QDF_DP_TRACE_MGMT_PACKET_RECORD,
  194. QDF_DP_TRACE_EVENT_RECORD,
  195. QDF_DP_TRACE_BASE_VERBOSITY,
  196. QDF_DP_TRACE_ICMP_PACKET_RECORD,
  197. QDF_DP_TRACE_ICMPv6_PACKET_RECORD,
  198. QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
  199. QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
  200. QDF_DP_TRACE_HDD_TX_TIMEOUT,
  201. QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
  202. QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
  203. QDF_DP_TRACE_LOW_VERBOSITY,
  204. QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
  205. QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
  206. QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
  207. QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
  208. QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
  209. QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
  210. QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
  211. QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD,
  212. QDF_DP_TRACE_MED_VERBOSITY,
  213. QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
  214. QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
  215. QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
  216. QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
  217. QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
  218. QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
  219. QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
  220. QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
  221. QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD,
  222. QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD,
  223. QDF_DP_TRACE_HIGH_VERBOSITY,
  224. QDF_DP_TRACE_MAX
  225. };
  226. /**
  227. * qdf_proto_dir - direction
  228. * @QDF_TX: TX direction
  229. * @QDF_RX: RX direction
  230. * @QDF_NA: not applicable
  231. */
  232. enum qdf_proto_dir {
  233. QDF_TX,
  234. QDF_RX,
  235. QDF_NA
  236. };
  237. /**
  238. * struct qdf_dp_trace_ptr_buf - pointer record buffer
  239. * @cookie: cookie value
  240. * @msdu_id: msdu_id
  241. * @status: completion status
  242. */
  243. struct qdf_dp_trace_ptr_buf {
  244. uint64_t cookie;
  245. uint16_t msdu_id;
  246. uint16_t status;
  247. };
  248. /**
  249. * struct qdf_dp_trace_proto_buf - proto packet buffer
  250. * @sa: source address
  251. * @da: destination address
  252. * @vdev_id : vdev id
  253. * @type: packet type
  254. * @subtype: packet subtype
  255. * @dir: direction
  256. */
  257. struct qdf_dp_trace_proto_buf {
  258. struct qdf_mac_addr sa;
  259. struct qdf_mac_addr da;
  260. uint8_t vdev_id;
  261. uint8_t type;
  262. uint8_t subtype;
  263. uint8_t dir;
  264. };
  265. /**
  266. * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
  267. * @vdev_id : vdev id
  268. * @type: packet type
  269. * @subtype: packet subtype
  270. */
  271. struct qdf_dp_trace_mgmt_buf {
  272. uint8_t vdev_id;
  273. uint8_t type;
  274. uint8_t subtype;
  275. };
  276. /**
  277. * struct qdf_dp_trace_event_buf - event buffer
  278. * @vdev_id : vdev id
  279. * @type: packet type
  280. * @subtype: packet subtype
  281. */
  282. struct qdf_dp_trace_event_buf {
  283. uint8_t vdev_id;
  284. uint8_t type;
  285. uint8_t subtype;
  286. };
  287. /**
  288. * struct qdf_dp_trace_record_s - Describes a record in DP trace
  289. * @time: time when it got stored
  290. * @code: Describes the particular event
  291. * @data: buffer to store data
  292. * @size: Length of the valid data stored in this record
  293. * @pid : process id which stored the data in this record
  294. */
  295. struct qdf_dp_trace_record_s {
  296. char time[20];
  297. uint8_t code;
  298. uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
  299. uint8_t size;
  300. uint32_t pid;
  301. uint8_t pdev_id;
  302. };
  303. /**
  304. * struct qdf_dp_trace_data - Parameters to configure/control DP trace
  305. * @head: Position of first record
  306. * @tail: Position of last record
  307. * @num: Current index
  308. * @proto_bitmap: defines which protocol to be traced
  309. * @no_of_record: defines every nth packet to be traced
  310. * @verbosity : defines verbosity level
  311. * @enable: enable/disable DP trace
  312. * @count: current packet number
  313. * @live_mode_config: configuration as received during initialization
  314. * @live_mode: current live mode, enabled or disabled.
  315. * @print_pkt_cnt: count of number of packets printed in live mode
  316. *.@high_tput_thresh: thresh beyond which live mode is turned off
  317. *.@thresh_time_limit: max time, in terms of BW timer intervals to wait,
  318. * for determining if high_tput_thresh has been crossed. ~1s
  319. *.@arp_req: stats for arp reqs
  320. *.@arp_resp: stats for arp resps
  321. *.@icmp_req: stats for icmp reqs
  322. *.@icmp_resp: stats for icmp resps
  323. *.@icmpv6_req: stats for icmpv6 reqs
  324. *.@icmpv6_resp: stats for icmpv6 resps
  325. *.@icmpv6_ns: stats for icmpv6 nss
  326. *.@icmpv6_na: stats for icmpv6 nas
  327. *.@icmpv6_rs: stats for icmpv6 rss
  328. *.@icmpv6_ra: stats for icmpv6 ras
  329. */
  330. struct s_qdf_dp_trace_data {
  331. uint32_t head;
  332. uint32_t tail;
  333. uint32_t num;
  334. uint8_t proto_bitmap;
  335. uint8_t no_of_record;
  336. uint8_t verbosity;
  337. bool enable;
  338. bool live_mode_config;
  339. bool live_mode;
  340. uint8_t print_pkt_cnt;
  341. uint8_t high_tput_thresh;
  342. uint16_t thresh_time_limit;
  343. /* Stats */
  344. uint32_t tx_count;
  345. uint32_t rx_count;
  346. uint32_t arp_req;
  347. uint32_t arp_resp;
  348. uint32_t icmp_req;
  349. uint32_t icmp_resp;
  350. uint32_t icmpv6_req;
  351. uint32_t icmpv6_resp;
  352. uint32_t icmpv6_ns;
  353. uint32_t icmpv6_na;
  354. uint32_t icmpv6_rs;
  355. uint32_t icmpv6_ra;
  356. };
  357. /* Function declarations and documenation */
  358. /**
  359. * qdf_trace_set_level() - Set the trace level for a particular module
  360. * @level : trace level
  361. *
  362. * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating
  363. * the severity of the condition causing the trace message to be issued.
  364. * More severe conditions are more likely to be logged.
  365. *
  366. * This is an external API that allows trace levels to be set for each module.
  367. *
  368. * Return: nothing
  369. */
  370. void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  371. /**
  372. * qdf_trace_get_level() - get the trace level
  373. * @level : trace level
  374. *
  375. * This is an external API that returns a bool value to signify if a
  376. * particular trace level is set for the specified module.
  377. * A member of the QDF_TRACE_LEVEL enumeration indicating the severity
  378. * of the condition causing the trace message to be issued.
  379. *
  380. * Note that individual trace levels are the only valid values
  381. * for this API. QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL
  382. * are not valid input and will return false
  383. *
  384. * Return:
  385. * false - the specified trace level for the specified module is OFF
  386. * true - the specified trace level for the specified module is ON
  387. */
  388. bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  389. typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
  390. typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
  391. void qdf_register_debugcb_init(void);
  392. void qdf_register_debug_callback(QDF_MODULE_ID module_id,
  393. tp_qdf_state_info_cb qdf_state_infocb);
  394. QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
  395. uint16_t *driver_dump_size);
  396. void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb);
  397. QDF_STATUS qdf_trace_spin_lock_init(void);
  398. void qdf_trace_init(void);
  399. void qdf_trace_enable(uint32_t, uint8_t enable);
  400. void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
  401. #ifdef CONFIG_DP_TRACE
  402. void qdf_dp_set_proto_bitmap(uint32_t val);
  403. void qdf_dp_trace_set_verbosity(uint32_t val);
  404. void qdf_dp_set_no_of_record(uint32_t val);
  405. bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
  406. enum qdf_proto_dir dir, uint8_t pdev_id);
  407. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  408. uint16_t time_limit, uint8_t verbosity,
  409. uint8_t proto_bitmap);
  410. void qdf_dp_trace_spin_lock_init(void);
  411. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  412. uint8_t verbosity);
  413. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
  414. void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
  415. uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
  416. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
  417. typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
  418. uint16_t, uint8_t, bool live);
  419. void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
  420. uint16_t index, uint8_t pdev_id, bool live);
  421. void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  422. uint8_t pdev_id, uint8_t *data, uint8_t size, uint16_t msdu_id,
  423. uint16_t status);
  424. void qdf_dp_trace_throttle_live_mode(bool high_bw_request);
  425. void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *pRecord,
  426. uint16_t recIndex, uint8_t pdev_id, bool live);
  427. void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
  428. uint16_t index, uint8_t pdev_id, bool live);
  429. uint8_t qdf_dp_get_proto_bitmap(void);
  430. uint8_t qdf_dp_get_verbosity(void);
  431. uint8_t qdf_dp_get_no_of_record(void);
  432. void
  433. qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  434. uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
  435. enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
  436. uint8_t pdev_id, bool print);
  437. void qdf_dp_trace_disable_live_mode(void);
  438. void qdf_dp_trace_enable_live_mode(void);
  439. void qdf_dp_trace_clear_buffer(void);
  440. void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  441. uint8_t pdev_id, enum qdf_proto_type type,
  442. enum qdf_proto_subtype subtype);
  443. void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
  444. uint16_t index, uint8_t pdev_id, bool live);
  445. void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
  446. uint16_t index, uint8_t pdev_id, bool live);
  447. void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  448. uint8_t pdev_id, enum qdf_proto_type type,
  449. enum qdf_proto_subtype subtype);
  450. #else
  451. static inline
  452. bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
  453. enum qdf_proto_dir dir, uint8_t pdev_id)
  454. {
  455. return false;
  456. }
  457. static inline
  458. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  459. uint16_t time_limit, uint8_t verbosity,
  460. uint8_t proto_bitmap)
  461. {
  462. }
  463. static inline
  464. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
  465. {
  466. }
  467. static inline
  468. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  469. uint8_t verbosity)
  470. {
  471. }
  472. static inline
  473. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
  474. {
  475. }
  476. static inline
  477. void qdf_dp_trace_disable_live_mode(void)
  478. {
  479. }
  480. static inline
  481. void qdf_dp_trace_enable_live_mode(void)
  482. {
  483. }
  484. static inline
  485. void qdf_dp_trace_throttle_live_mode(bool high_bw_request)
  486. {
  487. }
  488. static inline
  489. void qdf_dp_trace_clear_buffer(void)
  490. {
  491. }
  492. #endif
  493. void qdf_trace_display(void);
  494. void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  495. uint8_t on);
  496. void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level);
  497. void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
  498. char *str_format, ...);
  499. #define QDF_SNPRINTF qdf_snprintf
  500. #ifdef TSOSEG_DEBUG
  501. static inline
  502. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
  503. uint16_t caller)
  504. {
  505. int rc = -1;
  506. if (tsoseg != NULL) {
  507. tsoseg->dbg.cur++; tsoseg->dbg.cur &= 0x0f;
  508. tsoseg->dbg.history[tsoseg->dbg.cur] = caller;
  509. rc = tsoseg->dbg.cur;
  510. }
  511. return rc;
  512. };
  513. static inline void qdf_tso_seg_dbg_bug(char *msg)
  514. {
  515. qdf_print(msg);
  516. QDF_BUG(0);
  517. };
  518. static inline void
  519. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  520. {
  521. tsoseg->dbg.txdesc = owner;
  522. };
  523. static inline void
  524. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  525. {
  526. memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
  527. return;
  528. };
  529. #else
  530. static inline
  531. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
  532. uint16_t caller)
  533. {
  534. return 0;
  535. };
  536. static inline void qdf_tso_seg_dbg_bug(char *msg)
  537. {
  538. };
  539. static inline void
  540. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  541. {
  542. };
  543. static inline int
  544. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  545. {
  546. memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
  547. return 0;
  548. };
  549. #endif /* TSOSEG_DEBUG */
  550. void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  551. void *data, int buf_len);
  552. #define ERROR_CODE -1
  553. #define QDF_MAX_NAME_SIZE 32
  554. #define MAX_PRINT_CONFIG_SUPPORTED 32
  555. #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
  556. /**
  557. * qdf_set_pidx() - Sets the global qdf_pidx.
  558. * @pidx : Index of print control object assigned to the module
  559. *
  560. */
  561. void qdf_set_pidx(int pidx);
  562. /**
  563. * qdf_get_pidx() - Returns the global qdf_pidx.
  564. *
  565. * Return : Current qdf print index.
  566. */
  567. int qdf_get_pidx(void);
  568. /*
  569. * Shared print control index
  570. * for converged debug framework
  571. */
  572. #define QDF_PRINT_IDX_SHARED -1
  573. /**
  574. * QDF_PRINT_INFO() - Generic wrapper API for logging
  575. * @idx : Index of print control object
  576. * @module : Module identifier. A member of QDF_MODULE_ID enumeration that
  577. * identifies the module issuing the trace message
  578. * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
  579. * the severity of the condition causing the trace message to be
  580. * issued.
  581. * @str_format : Format string that contains the message to be logged.
  582. *
  583. *
  584. * This wrapper will be used for any generic logging messages. Wrapper will
  585. * compile a call to converged QDF trace message API.
  586. *
  587. * Return : Nothing
  588. *
  589. */
  590. void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
  591. QDF_TRACE_LEVEL level,
  592. char *str_format, ...);
  593. /**
  594. * struct category_info : Category information structure
  595. * @category_verbose_mask: Embeds information about category's verbose level
  596. */
  597. struct category_info {
  598. uint16_t category_verbose_mask;
  599. };
  600. /**
  601. * struct category_name_info : Category name information structure
  602. * @category_name_str: Embeds information about category name
  603. */
  604. struct category_name_info {
  605. unsigned char category_name_str[QDF_MAX_NAME_SIZE];
  606. };
  607. /**
  608. * qdf_trace_msg_cmn()- Converged logging API
  609. * @idx: Index of print control object assigned to the module
  610. * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
  611. * that identifies the category issuing the trace message.
  612. * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
  613. * indicating the severity of the condition causing the trace
  614. * message to be issued. More severe conditions are more likely
  615. * to be logged.
  616. * @str_format: Format string. The message to be logged. This format string
  617. * contains printf-like replacement parameters, which follow this
  618. * parameter in the variable argument list.
  619. * @val: Variable argument list part of the log message
  620. *
  621. * Return: nothing
  622. *
  623. */
  624. void qdf_trace_msg_cmn(unsigned int idx,
  625. QDF_MODULE_ID category,
  626. QDF_TRACE_LEVEL verbose,
  627. const char *str_format,
  628. va_list val);
  629. /**
  630. * struct qdf_print_ctrl: QDF Print Control structure
  631. * Statically allocated objects of print control
  632. * structure are declared that will support maximum of
  633. * 32 print control objects. Any module that needs to
  634. * register to the print control framework needs to
  635. * obtain a print control object using
  636. * qdf_print_ctrl_register API. It will have to pass
  637. * pointer to category info structure, name and
  638. * custom print function to be used if required.
  639. * @name : Optional name for the control object
  640. * @cat_info : Array of category_info struct
  641. * @custom_print : Custom print handler
  642. * @custom_ctxt : Custom print context
  643. * @dbglvlmac_on : Flag to enable/disable MAC level filtering
  644. * @in_use : Boolean to indicate if control object is in use
  645. */
  646. struct qdf_print_ctrl {
  647. char name[QDF_MAX_NAME_SIZE];
  648. struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
  649. void (*custom_print)(void *ctxt, const char *fmt, va_list args);
  650. void *custom_ctxt;
  651. #ifdef DBG_LVL_MAC_FILTERING
  652. unsigned char dbglvlmac_on;
  653. #endif
  654. bool in_use;
  655. };
  656. /**
  657. * qdf_print_ctrl_register() - Allocate QDF print control object, assign
  658. * pointer to category info or print control
  659. * structure and return the index to the callee
  660. * @cinfo : Pointer to array of category info structure
  661. * @custom_print_handler : Pointer to custom print handler
  662. * @custom_ctx : Pointer to custom context
  663. * @pctrl_name : Pointer to print control object name
  664. *
  665. * Return : Index of qdf_print_ctrl structure
  666. *
  667. */
  668. int qdf_print_ctrl_register(const struct category_info *cinfo,
  669. void *custom_print_handler,
  670. void *custom_ctx,
  671. const char *pctrl_name);
  672. /**
  673. * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
  674. * all categories set to the default level
  675. *
  676. * Return : void
  677. *
  678. */
  679. void qdf_shared_print_ctrl_init(void);
  680. /**
  681. * qdf_print_setup() - Setup default values to all the print control objects
  682. *
  683. * Register new print control object for the callee
  684. *
  685. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
  686. * on failure
  687. */
  688. QDF_STATUS qdf_print_setup(void);
  689. /**
  690. * qdf_print_ctrl_cleanup() - Clean up a print control object
  691. *
  692. * Cleanup the print control object for the callee
  693. *
  694. * @pctrl : Index of print control object
  695. *
  696. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
  697. */
  698. QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
  699. /**
  700. * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object
  701. *
  702. * Cleanup the shared print-ctrl-object
  703. *
  704. * Return : void
  705. */
  706. void qdf_shared_print_ctrl_cleanup(void);
  707. /**
  708. * qdf_print_set_category_verbose() - Enable/Disable category for a
  709. * print control object with
  710. * user provided verbose level
  711. *
  712. * @idx : Index of the print control object assigned to callee
  713. * @category : Category information
  714. * @verbose: Verbose information
  715. * @is_set: Flag indicating if verbose level needs to be enabled or disabled
  716. *
  717. * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  718. */
  719. QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
  720. QDF_MODULE_ID category,
  721. QDF_TRACE_LEVEL verbose,
  722. bool is_set);
  723. /**
  724. * qdf_print_is_category_enabled() - Get category information for the
  725. * print control object
  726. *
  727. * @idx : Index of print control object
  728. * @category : Category information
  729. *
  730. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  731. */
  732. bool qdf_print_is_category_enabled(unsigned int idx,
  733. QDF_MODULE_ID category);
  734. /**
  735. * qdf_print_is_verbose_enabled() - Get verbose information of a category for
  736. * the print control object
  737. *
  738. * @idx : Index of print control object
  739. * @category : Category information
  740. * @verbose : Verbose information
  741. *
  742. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  743. */
  744. bool qdf_print_is_verbose_enabled(unsigned int idx,
  745. QDF_MODULE_ID category,
  746. QDF_TRACE_LEVEL verbose);
  747. /**
  748. * qdf_print_clean_node_flag() - Clean up node flag for print control object
  749. *
  750. * @idx : Index of print control object
  751. *
  752. * Return : None
  753. */
  754. void qdf_print_clean_node_flag(unsigned int idx);
  755. #ifdef DBG_LVL_MAC_FILTERING
  756. /**
  757. * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
  758. *
  759. * @idx : Index of print control object
  760. * @enable : Enable/Disable bit sent by callee
  761. *
  762. * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
  763. */
  764. QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
  765. uint8_t enable);
  766. /**
  767. * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
  768. *
  769. * @idx : Index of print control object
  770. *
  771. * Return : Flag that indicates enable(1) or disable(0) or invalid(-1)
  772. */
  773. bool qdf_print_get_node_flag(unsigned int idx);
  774. #endif
  775. /**
  776. * qdf_logging_init() - Initialize msg logging functionality
  777. *
  778. *
  779. * Return : void
  780. */
  781. void qdf_logging_init(void);
  782. /**
  783. * qdf_logging_exit() - Cleanup msg logging functionality
  784. *
  785. *
  786. * Return : void
  787. */
  788. void qdf_logging_exit(void);
  789. #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
  790. /**
  791. * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
  792. * @buffer: the string buffer to print into
  793. * @addr: address of the symbol to lookup and print
  794. *
  795. * Return: number of characters printed
  796. */
  797. int qdf_sprint_symbol(char *buffer, void *addr);
  798. #endif /* __QDF_TRACE_H */