qdf_trace.h 28 KB

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