qdf_trace.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. /*
  2. * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #if !defined(__QDF_TRACE_H)
  19. #define __QDF_TRACE_H
  20. /**
  21. * DOC: qdf_trace
  22. * QCA driver framework trace APIs
  23. * Trace, logging, and debugging definitions and APIs
  24. */
  25. /* Include Files */
  26. #include <qdf_types.h> /* For QDF_MODULE_ID... */
  27. #include <stdarg.h> /* For va_list... */
  28. #include <qdf_status.h>
  29. #include <qdf_nbuf.h>
  30. #include <i_qdf_types.h>
  31. #include <qdf_debugfs.h>
  32. /* Type declarations */
  33. #define FL(x) "%s: %d: " x, __func__, __LINE__
  34. #define QDF_TRACE_BUFFER_SIZE (512)
  35. /*
  36. * Extracts the 8-bit group id from the wmi command id by performing the
  37. * reverse operation of WMI_CMD_GRP_START_ID
  38. */
  39. #define QDF_WMI_MTRACE_GRP_ID(message_id) (((message_id) >> 12) & 0xFF)
  40. /*
  41. * Number of bits reserved for WMI mtrace command id
  42. */
  43. #define QDF_WMI_MTRACE_CMD_NUM_BITS 7
  44. /*
  45. * Extracts the 7-bit group specific command id from the wmi command id
  46. */
  47. #define QDF_WMI_MTRACE_CMD_ID(message_id) ((message_id) & 0x7F)
  48. #ifdef CONFIG_MCL
  49. #define QDF_DEFAULT_TRACE_LEVEL \
  50. ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR))
  51. #else
  52. #define QDF_DEFAULT_TRACE_LEVEL (1 << QDF_TRACE_LEVEL_INFO)
  53. #endif
  54. #define QDF_CATEGORY_INFO_U16(val) (((val >> 16) & 0x0000FFFF))
  55. #define QDF_TRACE_LEVEL_INFO_L16(val) (val & 0x0000FFFF)
  56. typedef int (qdf_abstract_print)(void *priv, const char *fmt, ...);
  57. /*
  58. * Log levels
  59. */
  60. #define QDF_DEBUG_FUNCTRACE 0x01
  61. #define QDF_DEBUG_LEVEL0 0x02
  62. #define QDF_DEBUG_LEVEL1 0x04
  63. #define QDF_DEBUG_LEVEL2 0x08
  64. #define QDF_DEBUG_LEVEL3 0x10
  65. #define QDF_DEBUG_ERROR 0x20
  66. #define QDF_DEBUG_CFG 0x40
  67. /* DP Trace Implementation */
  68. #ifdef CONFIG_DP_TRACE
  69. #define DPTRACE(p) p
  70. #define DPTRACE_PRINT(args...) \
  71. QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG, args)
  72. #else
  73. #define DPTRACE(p)
  74. #define DPTRACE_PRINT(args...)
  75. #endif
  76. /* By default Data Path module will have all log levels enabled, except debug
  77. * log level. Debug level will be left up to the framework or user space modules
  78. * to be enabled when issue is detected
  79. */
  80. #define QDF_DATA_PATH_TRACE_LEVEL \
  81. ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \
  82. (1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \
  83. (1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \
  84. (1 << QDF_TRACE_LEVEL_INFO_LOW))
  85. /* Preprocessor definitions and constants */
  86. #define ASSERT_BUFFER_SIZE (512)
  87. #ifndef MAX_QDF_TRACE_RECORDS
  88. #define MAX_QDF_TRACE_RECORDS 4000
  89. #endif
  90. #define QDF_TRACE_DEFAULT_PDEV_ID 0xff
  91. #define INVALID_QDF_TRACE_ADDR 0xffffffff
  92. #define DEFAULT_QDF_TRACE_DUMP_COUNT 0
  93. /*
  94. * first parameter to iwpriv command - dump_dp_trace
  95. * iwpriv wlan0 dump_dp_trace 0 0 -> dump full buffer
  96. * iwpriv wlan0 dump_dp_trace 1 0 -> enable live view mode
  97. * iwpriv wlan0 dump_dp_trace 2 0 -> clear dp trace buffer
  98. * iwpriv wlan0 dump_dp_trace 3 0 -> disable live view mode
  99. */
  100. #define DUMP_DP_TRACE 0
  101. #define ENABLE_DP_TRACE_LIVE_MODE 1
  102. #define CLEAR_DP_TRACE_BUFFER 2
  103. #define DISABLE_DP_TRACE_LIVE_MODE 3
  104. #ifdef TRACE_RECORD
  105. #define MTRACE(p) p
  106. #else
  107. #define MTRACE(p) do { } while (0)
  108. #endif
  109. #define NO_SESSION 0xFF
  110. /**
  111. * typedef struct qdf_trace_record_s - keep trace record
  112. * @qtime: qtimer ticks
  113. * @time: user timestamp
  114. * @module: module name
  115. * @code: hold record of code
  116. * @session: hold record of session
  117. * @data: hold data
  118. * @pid: hold pid of the process
  119. */
  120. typedef struct qdf_trace_record_s {
  121. uint64_t qtime;
  122. char time[18];
  123. uint8_t module;
  124. uint8_t code;
  125. uint16_t session;
  126. uint32_t data;
  127. uint32_t pid;
  128. } qdf_trace_record_t, *tp_qdf_trace_record;
  129. /**
  130. * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer
  131. * @head: position of first record
  132. * @tail: position of last record
  133. * @num: count of total record
  134. * @num_since_last_dump: count from last dump
  135. * @enable: config for controlling the trace
  136. * @dump_count: Dump after number of records reach this number
  137. */
  138. typedef struct s_qdf_trace_data {
  139. uint32_t head;
  140. uint32_t tail;
  141. uint32_t num;
  142. uint16_t num_since_last_dump;
  143. uint8_t enable;
  144. uint16_t dump_count;
  145. } t_qdf_trace_data;
  146. #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
  147. #ifndef MAX_QDF_DP_TRACE_RECORDS
  148. #define MAX_QDF_DP_TRACE_RECORDS 2000
  149. #endif
  150. #define QDF_DP_TRACE_RECORD_SIZE 40
  151. #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff
  152. #define QDF_DP_TRACE_VERBOSITY_HIGH 4
  153. #define QDF_DP_TRACE_VERBOSITY_MEDIUM 3
  154. #define QDF_DP_TRACE_VERBOSITY_LOW 2
  155. #define QDF_DP_TRACE_VERBOSITY_ULTRA_LOW 1
  156. #define QDF_DP_TRACE_VERBOSITY_BASE 0
  157. /**
  158. * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
  159. * @QDF_DP_TRACE_INVALID - invalid
  160. * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet
  161. * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet
  162. * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet
  163. * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet
  164. * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt
  165. * @QDF_DP_TRACE_EVENT_RECORD - record events
  166. * @QDF_DP_TRACE_BASE_VERBOSITY - below this are part of base verbosity
  167. * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packet
  168. * @QDF_DP_TRACE_ICMPv6_PACKET_RECORD - record ICMPv6 packet
  169. * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout
  170. * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout
  171. * @QDF_DP_TRACE_ULTRA_LOW_VERBOSITY - Below this is not logged for >4PPS
  172. * @QDF_DP_TRACE_TX_PACKET_RECORD - record 32 bytes of tx pkt at any layer
  173. * @QDF_DP_TRACE_RX_PACKET_RECORD - record 32 bytes of rx pkt at any layer
  174. * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD
  175. * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD
  176. * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record data bytes of tx pkt at LI_DP
  177. * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record data bytes of rx pkt at LI_DP
  178. * @QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD - tx completion ptr record for
  179. * lithium
  180. * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record
  181. * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity
  182. * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record
  183. * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record
  184. * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record
  185. * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record
  186. * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record
  187. * @QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD- CE fastpath error record
  188. * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record
  189. * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record
  190. * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record
  191. * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity
  192. * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record
  193. * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  194. * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record
  195. * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record
  196. * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record
  197. * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record
  198. * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
  199. * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD
  200. * - record data bytes of rx null_queue pkt at LI_DP
  201. * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity
  202. */
  203. enum QDF_DP_TRACE_ID {
  204. QDF_DP_TRACE_INVALID,
  205. QDF_DP_TRACE_DROP_PACKET_RECORD,
  206. QDF_DP_TRACE_EAPOL_PACKET_RECORD,
  207. QDF_DP_TRACE_DHCP_PACKET_RECORD,
  208. QDF_DP_TRACE_ARP_PACKET_RECORD,
  209. QDF_DP_TRACE_MGMT_PACKET_RECORD,
  210. QDF_DP_TRACE_EVENT_RECORD,
  211. QDF_DP_TRACE_BASE_VERBOSITY,
  212. QDF_DP_TRACE_ICMP_PACKET_RECORD,
  213. QDF_DP_TRACE_ICMPv6_PACKET_RECORD,
  214. QDF_DP_TRACE_HDD_TX_TIMEOUT,
  215. QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
  216. QDF_DP_TRACE_ULTRA_LOW_VERBOSITY,
  217. QDF_DP_TRACE_TX_PACKET_RECORD,
  218. QDF_DP_TRACE_RX_PACKET_RECORD,
  219. QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
  220. QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
  221. QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
  222. QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD,
  223. QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD,
  224. QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
  225. QDF_DP_TRACE_LOW_VERBOSITY,
  226. QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
  227. QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
  228. QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
  229. QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
  230. QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
  231. QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD,
  232. QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
  233. QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
  234. QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD,
  235. QDF_DP_TRACE_MED_VERBOSITY,
  236. QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
  237. QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
  238. QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
  239. QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
  240. QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
  241. QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
  242. QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
  243. QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD,
  244. QDF_DP_TRACE_HIGH_VERBOSITY,
  245. QDF_DP_TRACE_MAX
  246. };
  247. /**
  248. * qdf_proto_dir - direction
  249. * @QDF_TX: TX direction
  250. * @QDF_RX: RX direction
  251. * @QDF_NA: not applicable
  252. */
  253. enum qdf_proto_dir {
  254. QDF_TX,
  255. QDF_RX,
  256. QDF_NA
  257. };
  258. /**
  259. * struct qdf_dp_trace_ptr_buf - pointer record buffer
  260. * @cookie: cookie value
  261. * @msdu_id: msdu_id
  262. * @status: completion status
  263. */
  264. struct qdf_dp_trace_ptr_buf {
  265. uint64_t cookie;
  266. uint16_t msdu_id;
  267. uint16_t status;
  268. };
  269. /**
  270. * struct qdf_dp_trace_proto_buf - proto packet buffer
  271. * @sa: source address
  272. * @da: destination address
  273. * @vdev_id : vdev id
  274. * @type: packet type
  275. * @subtype: packet subtype
  276. * @dir: direction
  277. */
  278. struct qdf_dp_trace_proto_buf {
  279. struct qdf_mac_addr sa;
  280. struct qdf_mac_addr da;
  281. uint8_t vdev_id;
  282. uint8_t type;
  283. uint8_t subtype;
  284. uint8_t dir;
  285. };
  286. /**
  287. * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
  288. * @vdev_id : vdev id
  289. * @type: packet type
  290. * @subtype: packet subtype
  291. */
  292. struct qdf_dp_trace_mgmt_buf {
  293. uint8_t vdev_id;
  294. uint8_t type;
  295. uint8_t subtype;
  296. };
  297. /**
  298. * struct qdf_dp_trace_event_buf - event buffer
  299. * @vdev_id : vdev id
  300. * @type: packet type
  301. * @subtype: packet subtype
  302. */
  303. struct qdf_dp_trace_event_buf {
  304. uint8_t vdev_id;
  305. uint8_t type;
  306. uint8_t subtype;
  307. };
  308. /**
  309. * struct qdf_dp_trace_data_buf - nbuf data buffer
  310. * @msdu_id : msdu id
  311. */
  312. struct qdf_dp_trace_data_buf {
  313. uint16_t msdu_id;
  314. };
  315. /**
  316. * struct qdf_dp_trace_record_s - Describes a record in DP trace
  317. * @time: time when it got stored
  318. * @code: Describes the particular event
  319. * @data: buffer to store data
  320. * @size: Length of the valid data stored in this record
  321. * @pid : process id which stored the data in this record
  322. */
  323. struct qdf_dp_trace_record_s {
  324. uint64_t time;
  325. uint8_t code;
  326. uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
  327. uint8_t size;
  328. uint32_t pid;
  329. uint8_t pdev_id;
  330. };
  331. /**
  332. * struct qdf_dp_trace_data - Parameters to configure/control DP trace
  333. * @head: Position of first record
  334. * @tail: Position of last record
  335. * @num: Current index
  336. * @proto_bitmap: defines which protocol to be traced
  337. * @no_of_record: defines every nth packet to be traced
  338. * @num_records_to_dump: defines number of records to be dumped
  339. * @dump_counter: counter to track number of records dumped
  340. * @verbosity : defines verbosity level
  341. * @ini_conf_verbosity: Configured verbosity from INI
  342. * @enable: enable/disable DP trace
  343. * @count: current packet number
  344. * @live_mode_config: configuration as received during initialization
  345. * @live_mode: current live mode, enabled or disabled, can be throttled based
  346. * on throughput
  347. * @force_live_mode: flag to enable live mode all the time for all packets.
  348. * This can be set/unset from userspace and overrides other
  349. * live mode flags.
  350. * @dynamic_verbosity_modify: Dynamic user configured verbosity overrides all
  351. * @print_pkt_cnt: count of number of packets printed in live mode
  352. * @high_tput_thresh: thresh beyond which live mode is turned off
  353. * @thresh_time_limit: max time, in terms of BW timer intervals to wait,
  354. * for determining if high_tput_thresh has been crossed. ~1s
  355. * @arp_req: stats for arp reqs
  356. * @arp_resp: stats for arp resps
  357. * @icmp_req: stats for icmp reqs
  358. * @icmp_resp: stats for icmp resps
  359. * @dhcp_disc: stats for dhcp discover msgs
  360. * @dhcp_req: stats for dhcp req msgs
  361. * @dhcp_off: stats for dhcp offer msgs
  362. * @dhcp_ack: stats for dhcp ack msgs
  363. * @dhcp_nack: stats for dhcp nack msgs
  364. * @dhcp_others: stats for other dhcp pkts types
  365. * @eapol_m1: stats for eapol m1
  366. * @eapol_m2: stats for eapol m2
  367. * @eapol_m3: stats for eapol m3
  368. * @eapol_m4: stats for eapol m4
  369. * @eapol_others: stats for other eapol pkt types
  370. * @icmpv6_req: stats for icmpv6 reqs
  371. * @icmpv6_resp: stats for icmpv6 resps
  372. * @icmpv6_ns: stats for icmpv6 nss
  373. * @icmpv6_na: stats for icmpv6 nas
  374. * @icmpv6_rs: stats for icmpv6 rss
  375. * @icmpv6_ra: stats for icmpv6 ras
  376. */
  377. struct s_qdf_dp_trace_data {
  378. uint32_t head;
  379. uint32_t tail;
  380. uint32_t num;
  381. uint8_t proto_bitmap;
  382. uint8_t no_of_record;
  383. uint16_t num_records_to_dump;
  384. uint16_t dump_counter;
  385. uint8_t verbosity;
  386. uint8_t ini_conf_verbosity;
  387. bool enable;
  388. bool live_mode_config;
  389. bool live_mode;
  390. uint32_t curr_pos;
  391. uint32_t saved_tail;
  392. bool force_live_mode;
  393. bool dynamic_verbosity_modify;
  394. uint8_t print_pkt_cnt;
  395. uint8_t high_tput_thresh;
  396. uint16_t thresh_time_limit;
  397. /* Stats */
  398. uint32_t tx_count;
  399. uint32_t rx_count;
  400. u16 arp_req;
  401. u16 arp_resp;
  402. u16 dhcp_disc;
  403. u16 dhcp_req;
  404. u16 dhcp_off;
  405. u16 dhcp_ack;
  406. u16 dhcp_nack;
  407. u16 dhcp_others;
  408. u16 eapol_m1;
  409. u16 eapol_m2;
  410. u16 eapol_m3;
  411. u16 eapol_m4;
  412. u16 eapol_others;
  413. u16 icmp_req;
  414. u16 icmp_resp;
  415. u16 icmpv6_req;
  416. u16 icmpv6_resp;
  417. u16 icmpv6_ns;
  418. u16 icmpv6_na;
  419. u16 icmpv6_rs;
  420. u16 icmpv6_ra;
  421. };
  422. /**
  423. * struct qdf_dpt_debugfs_state - state to control read to debugfs file
  424. * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID: invalid state
  425. * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT: initial state
  426. * @QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS: read is in progress
  427. * @QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE: read complete
  428. */
  429. enum qdf_dpt_debugfs_state {
  430. QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID,
  431. QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT,
  432. QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS,
  433. QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE,
  434. };
  435. /* Function declarations and documenation */
  436. /**
  437. * qdf_trace_set_level() - Set the trace level for a particular module
  438. * @level : trace level
  439. *
  440. * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating
  441. * the severity of the condition causing the trace message to be issued.
  442. * More severe conditions are more likely to be logged.
  443. *
  444. * This is an external API that allows trace levels to be set for each module.
  445. *
  446. * Return: nothing
  447. */
  448. void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  449. /**
  450. * qdf_trace_get_level() - get the trace level
  451. * @level : trace level
  452. *
  453. * This is an external API that returns a bool value to signify if a
  454. * particular trace level is set for the specified module.
  455. * A member of the QDF_TRACE_LEVEL enumeration indicating the severity
  456. * of the condition causing the trace message to be issued.
  457. *
  458. * Note that individual trace levels are the only valid values
  459. * for this API. QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL
  460. * are not valid input and will return false
  461. *
  462. * Return:
  463. * false - the specified trace level for the specified module is OFF
  464. * true - the specified trace level for the specified module is ON
  465. */
  466. bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
  467. typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
  468. typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
  469. #ifdef WLAN_FEATURE_MEMDUMP_ENABLE
  470. void qdf_register_debugcb_init(void);
  471. void qdf_register_debug_callback(QDF_MODULE_ID module_id,
  472. tp_qdf_state_info_cb qdf_state_infocb);
  473. QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
  474. uint16_t *driver_dump_size);
  475. #else /* WLAN_FEATURE_MEMDUMP_ENABLE */
  476. static inline void qdf_register_debugcb_init(void)
  477. {
  478. }
  479. #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
  480. #ifdef TRACE_RECORD
  481. void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb);
  482. void qdf_trace_init(void);
  483. void qdf_trace_deinit(void);
  484. void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data);
  485. void qdf_trace_enable(uint32_t, uint8_t enable);
  486. void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
  487. QDF_STATUS qdf_trace_spin_lock_init(void);
  488. #else
  489. #ifdef CONFIG_MCL
  490. static inline
  491. void qdf_trace_init(void)
  492. {
  493. }
  494. static inline
  495. void qdf_trace_deinit(void)
  496. {
  497. }
  498. static inline
  499. void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable)
  500. {
  501. }
  502. static inline
  503. void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data)
  504. {
  505. }
  506. static inline
  507. void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session,
  508. uint32_t count, uint32_t bitmask_of_module)
  509. {
  510. }
  511. static inline
  512. QDF_STATUS qdf_trace_spin_lock_init(void)
  513. {
  514. return QDF_STATUS_E_INVAL;
  515. }
  516. #endif
  517. #endif
  518. #ifdef ENABLE_MTRACE_LOG
  519. /**
  520. * qdf_mtrace_log() - Logs a message tracepoint to DIAG
  521. * Infrastructure.
  522. * @src_module: Enum of source module (basically module id)
  523. * from where the message with message_id is posted.
  524. * @dst_module: Enum of destination module (basically module id)
  525. * to which the message with message_id is posted.
  526. * @message_id: Id of the message to be posted
  527. * @vdev_id: Vdev Id
  528. *
  529. * This function logs to the DIAG Infrastructure a tracepoint for a
  530. * message being sent from a source module to a destination module
  531. * with a specific ID for the benefit of a specific vdev.
  532. * For non-vdev messages vdev_id will be NO_SESSION
  533. * Return: None
  534. */
  535. void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  536. uint16_t message_id, uint8_t vdev_id);
  537. #else
  538. static inline
  539. void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  540. uint16_t message_id, uint8_t vdev_id)
  541. {
  542. }
  543. #endif
  544. #ifdef TRACE_RECORD
  545. /**
  546. * qdf_mtrace() - puts the messages in to ring-buffer
  547. * and logs a message tracepoint to DIAG Infrastructure.
  548. * @src_module: Enum of source module (basically module id)
  549. * from where the message with message_id is posted.
  550. * @dst_module: Enum of destination module (basically module id)
  551. * to which the message with message_id is posted.
  552. * @message_id: Id of the message to be posted
  553. * @vdev_id: Vdev Id
  554. * @data: Actual message contents
  555. *
  556. * This function will be called from each module which wants to record the
  557. * messages in circular queue. Before calling this function make sure you
  558. * have registered your module with qdf through qdf_trace_register function.
  559. * In addition of the recording the messages in circular queue this function
  560. * will log the message tracepoint to the DIAG infrastructure.
  561. * these logs will be later used by post processing script.
  562. *
  563. * Return: None
  564. */
  565. void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  566. uint16_t message_id, uint8_t vdev_id, uint32_t data);
  567. #else
  568. static inline
  569. void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  570. uint16_t message_id, uint8_t vdev_id, uint32_t data)
  571. {
  572. }
  573. #endif
  574. #ifdef CONFIG_DP_TRACE
  575. void qdf_dp_set_proto_bitmap(uint32_t val);
  576. void qdf_dp_trace_set_verbosity(uint32_t val);
  577. void qdf_dp_set_no_of_record(uint32_t val);
  578. #define QDF_DP_TRACE_RECORD_INFO_LIVE (0x1)
  579. #define QDF_DP_TRACE_RECORD_INFO_THROTTLED (0x1 << 1)
  580. /**
  581. * qdf_dp_trace_log_pkt() - log packet type enabled through iwpriv
  582. * @vdev_id: vdev_id
  583. * @skb: skb pointer
  584. * @dir: direction
  585. * @pdev_id: pdev_id
  586. *
  587. * Return: true: some protocol was logged, false: no protocol was logged.
  588. */
  589. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  590. enum qdf_proto_dir dir, uint8_t pdev_id);
  591. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  592. uint16_t time_limit, uint8_t verbosity,
  593. uint8_t proto_bitmap);
  594. void qdf_dp_trace_deinit(void);
  595. void qdf_dp_trace_spin_lock_init(void);
  596. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  597. uint8_t verbosity);
  598. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
  599. void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
  600. uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
  601. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
  602. /**
  603. * qdf_dpt_get_curr_pos_debugfs() - get curr position to start read
  604. * @file: debugfs file to read
  605. * @state: state to control read to debugfs file
  606. *
  607. * Return: curr pos
  608. */
  609. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  610. enum qdf_dpt_debugfs_state state);
  611. /**
  612. * qdf_dpt_dump_stats_debugfs() - dump DP Trace stats to debugfs file
  613. * @file: debugfs file to read
  614. * @curr_pos: curr position to start read
  615. *
  616. * Return: QDF_STATUS
  617. */
  618. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  619. uint32_t curr_pos);
  620. /**
  621. * qdf_dpt_set_value_debugfs() - set value of DP Trace debugfs params
  622. * @proto_bitmap: defines which protocol to be traced
  623. * @no_of_record: defines every nth packet to be traced
  624. * @verbosity : defines verbosity level
  625. * @num_records_to_dump: defines number of records to be dumped
  626. *
  627. * Return: none
  628. */
  629. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  630. uint8_t verbosity, uint16_t num_records_to_dump);
  631. /**
  632. * qdf_dp_trace_dump_stats() - dump DP Trace stats
  633. *
  634. * Return: none
  635. */
  636. void qdf_dp_trace_dump_stats(void);
  637. typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
  638. uint16_t, uint8_t, uint8_t info);
  639. /**
  640. * qdf_dp_display_record() - Displays a record in DP trace
  641. * @record: pointer to a record in DP trace
  642. * @index: record index
  643. * @pdev_id: pdev id for the mgmt pkt
  644. * @info: info used to display pkt (live mode, throttling)
  645. *
  646. * Return: None
  647. */
  648. void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
  649. uint16_t index, uint8_t pdev_id,
  650. uint8_t info);
  651. /**
  652. * qdf_dp_display_ptr_record() - display record
  653. * @record: dptrace record
  654. * @rec_index: index
  655. * @pdev_id: pdev id for the mgmt pkt
  656. * @info: info used to display pkt (live mode, throttling)
  657. *
  658. * Return: none
  659. */
  660. void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record,
  661. uint16_t rec_index, uint8_t pdev_id,
  662. uint8_t info);
  663. /**
  664. * qdf_dp_display_proto_pkt_debug() - display proto packet only
  665. * for debug.
  666. * @record: dptrace record
  667. * @index: index
  668. * @pdev_id: pdev id for the mgmt pkt
  669. * @info: info used to display pkt (live mode, throttling)
  670. *
  671. * Return: none
  672. */
  673. void qdf_dp_display_proto_pkt_debug(struct qdf_dp_trace_record_s *record,
  674. uint16_t index, uint8_t pdev_id,
  675. uint8_t info);
  676. /**
  677. * qdf_dp_display_proto_pkt_always() - display proto packets all
  678. * the time.
  679. * @record: dptrace record
  680. * @index: index
  681. * @pdev_id: pdev id for the mgmt pkt
  682. * @info: info used to display pkt (live mode, throttling)
  683. *
  684. * Return: none
  685. */
  686. void qdf_dp_display_proto_pkt_always(struct qdf_dp_trace_record_s *record,
  687. uint16_t index, uint8_t pdev_id,
  688. uint8_t info);
  689. /**
  690. * qdf_dp_display_data_pkt_record() - Displays a data packet in DP trace
  691. * @record: pointer to a record in DP trace
  692. * @rec_index: record index
  693. * @pdev_id: pdev id
  694. * @info: display info regarding record
  695. *
  696. * Return: None
  697. */
  698. void
  699. qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record,
  700. uint16_t rec_index, uint8_t pdev_id,
  701. uint8_t info);
  702. void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  703. uint8_t pdev_id, uint8_t *data, uint8_t size,
  704. uint16_t msdu_id, uint16_t status);
  705. void qdf_dp_trace_throttle_live_mode(bool high_bw_request);
  706. /**
  707. * qdf_dp_trace_tput_policy() - Change verbosity based on the TPUT
  708. * @is_data_traffic: Is traffic more than low TPUT threashould
  709. *
  710. * Return: None
  711. */
  712. void qdf_dp_trace_apply_tput_policy(bool is_data_traffic);
  713. /**
  714. * qdf_dp_trace_data_pkt() - trace data packet
  715. * @nbuf: nbuf which needs to be traced
  716. * @pdev_id: pdev_id
  717. * @code: QDF_DP_TRACE_ID for the packet (TX or RX)
  718. * @msdu_id: tx desc id for the nbuf (Only applies to TX packets)
  719. * @dir: TX or RX packet direction
  720. *
  721. * Return: None
  722. */
  723. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  724. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  725. enum qdf_proto_dir dir);
  726. uint8_t qdf_dp_get_proto_bitmap(void);
  727. uint8_t qdf_dp_get_verbosity(void);
  728. uint8_t qdf_dp_get_no_of_record(void);
  729. /**
  730. * qdf_dp_trace_proto_pkt() - record proto packet
  731. * @code: dptrace code
  732. * @vdev_id: vdev id
  733. * @sa: source mac address
  734. * @da: destination mac address
  735. * @type: proto type
  736. * @subtype: proto subtype
  737. * @dir: direction
  738. * @pdev_id: pdev id
  739. * @print: to print this proto pkt or not
  740. *
  741. * Return: none
  742. */
  743. void
  744. qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  745. uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
  746. enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
  747. uint8_t pdev_id, bool print);
  748. void qdf_dp_trace_disable_live_mode(void);
  749. void qdf_dp_trace_enable_live_mode(void);
  750. void qdf_dp_trace_clear_buffer(void);
  751. /**
  752. * qdf_dp_trace_mgmt_pkt() - record mgmt packet
  753. * @code: dptrace code
  754. * @vdev_id: vdev id
  755. * @pdev_id: pdev_id
  756. * @type: proto type
  757. * @subtype: proto subtype
  758. *
  759. * Return: none
  760. */
  761. void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  762. uint8_t pdev_id, enum qdf_proto_type type,
  763. enum qdf_proto_subtype subtype);
  764. /**
  765. * qdf_dp_display_mgmt_pkt() - display proto packet
  766. * @record: dptrace record
  767. * @index: index
  768. * @pdev_id: pdev id for the mgmt pkt
  769. * @info: info used to display pkt (live mode, throttling)
  770. *
  771. * Return: none
  772. */
  773. void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
  774. uint16_t index, uint8_t pdev_id, uint8_t info);
  775. /**
  776. * qdf_dp_display_event_record() - display event records
  777. * @record: dptrace record
  778. * @index: index
  779. * @pdev_id: pdev id for the mgmt pkt
  780. * @info: info used to display pkt (live mode, throttling)
  781. *
  782. * Return: none
  783. */
  784. void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
  785. uint16_t index, uint8_t pdev_id, uint8_t info);
  786. void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  787. uint8_t pdev_id, enum qdf_proto_type type,
  788. enum qdf_proto_subtype subtype);
  789. #else
  790. static inline
  791. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  792. enum qdf_proto_dir dir, uint8_t pdev_id)
  793. {
  794. return false;
  795. }
  796. static inline
  797. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  798. uint16_t time_limit, uint8_t verbosity,
  799. uint8_t proto_bitmap)
  800. {
  801. }
  802. static inline
  803. void qdf_dp_trace_deinit(void)
  804. {
  805. }
  806. static inline
  807. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
  808. {
  809. }
  810. static inline
  811. void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
  812. uint8_t verbosity)
  813. {
  814. }
  815. static inline
  816. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
  817. {
  818. }
  819. static inline
  820. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  821. enum qdf_dpt_debugfs_state state)
  822. {
  823. return 0;
  824. }
  825. static inline
  826. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  827. uint32_t curr_pos)
  828. {
  829. return QDF_STATUS_SUCCESS;
  830. }
  831. static inline
  832. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  833. uint8_t verbosity, uint16_t num_records_to_dump)
  834. {
  835. }
  836. static inline void qdf_dp_trace_dump_stats(void)
  837. {
  838. }
  839. static inline
  840. void qdf_dp_trace_disable_live_mode(void)
  841. {
  842. }
  843. static inline
  844. void qdf_dp_trace_enable_live_mode(void)
  845. {
  846. }
  847. static inline
  848. void qdf_dp_trace_throttle_live_mode(bool high_bw_request)
  849. {
  850. }
  851. static inline
  852. void qdf_dp_trace_clear_buffer(void)
  853. {
  854. }
  855. static inline
  856. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  857. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  858. enum qdf_proto_dir dir)
  859. {
  860. }
  861. #endif
  862. void qdf_trace_display(void);
  863. void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  864. uint8_t on);
  865. void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level);
  866. void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
  867. char *str_format, ...);
  868. #define QDF_SNPRINTF qdf_snprintf
  869. #ifdef TSOSEG_DEBUG
  870. static inline void qdf_tso_seg_dbg_bug(char *msg)
  871. {
  872. qdf_print("%s", msg);
  873. QDF_BUG(0);
  874. };
  875. /**
  876. * qdf_tso_seg_dbg_init - initialize TSO segment debug structure
  877. * @tsoseg : structure to initialize
  878. *
  879. * TSO segment dbg structures are attached to qdf_tso_seg_elem_t
  880. * structures and are allocated only of TSOSEG_DEBUG is defined.
  881. * When allocated, at the time of the tso_seg_pool initialization,
  882. * which goes with tx_desc initialization (1:1), each structure holds
  883. * a number of (currently 16) history entries, basically describing
  884. * what operation has been performed on this particular tso_seg_elem.
  885. * This history buffer is a circular buffer and the current index is
  886. * held in an atomic variable called cur. It is incremented every
  887. * operation. Each of these operations are added with the function
  888. * qdf_tso_seg_dbg_record.
  889. * For each segment, this initialization function MUST be called PRIOR
  890. * TO any _dbg_record() function calls.
  891. * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero)
  892. * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element.
  893. *
  894. * Return:
  895. * None
  896. */
  897. static inline
  898. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  899. {
  900. tsoseg->dbg.txdesc = NULL;
  901. qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */
  902. }
  903. /**
  904. * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure
  905. * @tsoseg : structure to initialize
  906. * @id : operation ID (identifies the caller)
  907. *
  908. * Adds a history entry to the history circular buffer. Each entry
  909. * contains an operation id (caller, as currently each ID is used only
  910. * once in the source, so it directly identifies the src line that invoked
  911. * the recording.
  912. *
  913. * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized
  914. * by qdf_tso_seg_dbg_init.
  915. *
  916. * The entry to be added is written at the location pointed by the atomic
  917. * variable called cur. Cur is an ever increasing atomic variable. It is
  918. * masked so that only the lower 4 bits are used (16 history entries).
  919. *
  920. * Return:
  921. * int: the entry this record was recorded at
  922. */
  923. static inline
  924. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  925. {
  926. int rc = -1;
  927. unsigned int c;
  928. qdf_assert(tsoseg);
  929. if (id == TSOSEG_LOC_ALLOC) {
  930. c = qdf_atomic_read(&tsoseg->dbg.cur);
  931. /* dont crash on the very first alloc on the segment */
  932. c &= 0x0f;
  933. /* allow only INIT and FREE ops before ALLOC */
  934. if (tsoseg->dbg.h[c].id >= id)
  935. qdf_tso_seg_dbg_bug("Rogue TSO seg alloc");
  936. }
  937. c = qdf_atomic_inc_return(&tsoseg->dbg.cur);
  938. c &= 0x0f;
  939. tsoseg->dbg.h[c].ts = qdf_get_log_timestamp();
  940. tsoseg->dbg.h[c].id = id;
  941. rc = c;
  942. return rc;
  943. };
  944. static inline void
  945. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  946. {
  947. if (tsoseg)
  948. tsoseg->dbg.txdesc = owner;
  949. };
  950. static inline void
  951. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  952. {
  953. memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
  954. return;
  955. };
  956. #else
  957. static inline
  958. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  959. {
  960. };
  961. static inline
  962. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  963. {
  964. return 0;
  965. };
  966. static inline void qdf_tso_seg_dbg_bug(char *msg)
  967. {
  968. };
  969. static inline void
  970. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  971. {
  972. };
  973. static inline int
  974. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  975. {
  976. memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
  977. return 0;
  978. };
  979. #endif /* TSOSEG_DEBUG */
  980. void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  981. void *data, int buf_len);
  982. #define ERROR_CODE -1
  983. #define QDF_MAX_NAME_SIZE 32
  984. #define MAX_PRINT_CONFIG_SUPPORTED 32
  985. #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
  986. /**
  987. * qdf_set_pidx() - Sets the global qdf_pidx.
  988. * @pidx : Index of print control object assigned to the module
  989. *
  990. */
  991. void qdf_set_pidx(int pidx);
  992. /**
  993. * qdf_get_pidx() - Returns the global qdf_pidx.
  994. *
  995. * Return : Current qdf print index.
  996. */
  997. int qdf_get_pidx(void);
  998. /*
  999. * Shared print control index
  1000. * for converged debug framework
  1001. */
  1002. #define QDF_PRINT_IDX_SHARED -1
  1003. /**
  1004. * QDF_PRINT_INFO() - Generic wrapper API for logging
  1005. * @idx : Index of print control object
  1006. * @module : Module identifier. A member of QDF_MODULE_ID enumeration that
  1007. * identifies the module issuing the trace message
  1008. * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
  1009. * the severity of the condition causing the trace message to be
  1010. * issued.
  1011. * @str_format : Format string that contains the message to be logged.
  1012. *
  1013. *
  1014. * This wrapper will be used for any generic logging messages. Wrapper will
  1015. * compile a call to converged QDF trace message API.
  1016. *
  1017. * Return : Nothing
  1018. *
  1019. */
  1020. void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
  1021. QDF_TRACE_LEVEL level,
  1022. char *str_format, ...);
  1023. /**
  1024. * struct category_info : Category information structure
  1025. * @category_verbose_mask: Embeds information about category's verbose level
  1026. */
  1027. struct category_info {
  1028. uint16_t category_verbose_mask;
  1029. };
  1030. /**
  1031. * struct category_name_info : Category name information structure
  1032. * @category_name_str: Embeds information about category name
  1033. */
  1034. struct category_name_info {
  1035. unsigned char category_name_str[QDF_MAX_NAME_SIZE];
  1036. };
  1037. /**
  1038. * qdf_trace_msg_cmn()- Converged logging API
  1039. * @idx: Index of print control object assigned to the module
  1040. * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
  1041. * that identifies the category issuing the trace message.
  1042. * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
  1043. * indicating the severity of the condition causing the trace
  1044. * message to be issued. More severe conditions are more likely
  1045. * to be logged.
  1046. * @str_format: Format string. The message to be logged. This format string
  1047. * contains printf-like replacement parameters, which follow this
  1048. * parameter in the variable argument list.
  1049. * @val: Variable argument list part of the log message
  1050. *
  1051. * Return: nothing
  1052. *
  1053. */
  1054. void qdf_trace_msg_cmn(unsigned int idx,
  1055. QDF_MODULE_ID category,
  1056. QDF_TRACE_LEVEL verbose,
  1057. const char *str_format,
  1058. va_list val);
  1059. /**
  1060. * struct qdf_print_ctrl: QDF Print Control structure
  1061. * Statically allocated objects of print control
  1062. * structure are declared that will support maximum of
  1063. * 32 print control objects. Any module that needs to
  1064. * register to the print control framework needs to
  1065. * obtain a print control object using
  1066. * qdf_print_ctrl_register API. It will have to pass
  1067. * pointer to category info structure, name and
  1068. * custom print function to be used if required.
  1069. * @name : Optional name for the control object
  1070. * @cat_info : Array of category_info struct
  1071. * @custom_print : Custom print handler
  1072. * @custom_ctxt : Custom print context
  1073. * @dbglvlmac_on : Flag to enable/disable MAC level filtering
  1074. * @in_use : Boolean to indicate if control object is in use
  1075. */
  1076. struct qdf_print_ctrl {
  1077. char name[QDF_MAX_NAME_SIZE];
  1078. struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
  1079. void (*custom_print)(void *ctxt, const char *fmt, va_list args);
  1080. void *custom_ctxt;
  1081. #ifdef DBG_LVL_MAC_FILTERING
  1082. unsigned char dbglvlmac_on;
  1083. #endif
  1084. bool in_use;
  1085. };
  1086. /**
  1087. * qdf_print_ctrl_register() - Allocate QDF print control object, assign
  1088. * pointer to category info or print control
  1089. * structure and return the index to the callee
  1090. * @cinfo : Pointer to array of category info structure
  1091. * @custom_print_handler : Pointer to custom print handler
  1092. * @custom_ctx : Pointer to custom context
  1093. * @pctrl_name : Pointer to print control object name
  1094. *
  1095. * Return : Index of qdf_print_ctrl structure
  1096. *
  1097. */
  1098. int qdf_print_ctrl_register(const struct category_info *cinfo,
  1099. void *custom_print_handler,
  1100. void *custom_ctx,
  1101. const char *pctrl_name);
  1102. /**
  1103. * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
  1104. * all categories set to the default level
  1105. *
  1106. * Return : void
  1107. *
  1108. */
  1109. void qdf_shared_print_ctrl_init(void);
  1110. /**
  1111. * qdf_print_setup() - Setup default values to all the print control objects
  1112. *
  1113. * Register new print control object for the callee
  1114. *
  1115. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
  1116. * on failure
  1117. */
  1118. QDF_STATUS qdf_print_setup(void);
  1119. /**
  1120. * qdf_print_ctrl_cleanup() - Clean up a print control object
  1121. *
  1122. * Cleanup the print control object for the callee
  1123. *
  1124. * @pctrl : Index of print control object
  1125. *
  1126. * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
  1127. */
  1128. QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
  1129. /**
  1130. * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object
  1131. *
  1132. * Cleanup the shared print-ctrl-object
  1133. *
  1134. * Return : void
  1135. */
  1136. void qdf_shared_print_ctrl_cleanup(void);
  1137. /**
  1138. * qdf_print_set_category_verbose() - Enable/Disable category for a
  1139. * print control object with
  1140. * user provided verbose level
  1141. *
  1142. * @idx : Index of the print control object assigned to callee
  1143. * @category : Category information
  1144. * @verbose: Verbose information
  1145. * @is_set: Flag indicating if verbose level needs to be enabled or disabled
  1146. *
  1147. * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1148. */
  1149. QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
  1150. QDF_MODULE_ID category,
  1151. QDF_TRACE_LEVEL verbose,
  1152. bool is_set);
  1153. /**
  1154. * qdf_log_dump_at_kernel_level() - Enable/Disable printk call
  1155. * @enable: Indicates whether printk is enabled in QDF_TRACE
  1156. *
  1157. * Return: void
  1158. */
  1159. void qdf_log_dump_at_kernel_level(bool enable);
  1160. /**
  1161. * qdf_logging_set_flush_timer() - Set the time period in which host logs
  1162. * should be flushed out to user-space
  1163. * @milliseconds: milliseconds after which the logs should be flushed out to
  1164. * user-space
  1165. *
  1166. * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1167. */
  1168. int qdf_logging_set_flush_timer(uint32_t milliseconds);
  1169. /**
  1170. * qdf_logging_flush_logs() - Flush out the logs to user-space one time
  1171. *
  1172. * Return: void
  1173. */
  1174. void qdf_logging_flush_logs(void);
  1175. /**
  1176. * qdf_print_is_category_enabled() - Get category information for the
  1177. * print control object
  1178. *
  1179. * @idx : Index of print control object
  1180. * @category : Category information
  1181. *
  1182. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  1183. */
  1184. bool qdf_print_is_category_enabled(unsigned int idx,
  1185. QDF_MODULE_ID category);
  1186. /**
  1187. * qdf_print_is_verbose_enabled() - Get verbose information of a category for
  1188. * the print control object
  1189. *
  1190. * @idx : Index of print control object
  1191. * @category : Category information
  1192. * @verbose : Verbose information
  1193. *
  1194. * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
  1195. */
  1196. bool qdf_print_is_verbose_enabled(unsigned int idx,
  1197. QDF_MODULE_ID category,
  1198. QDF_TRACE_LEVEL verbose);
  1199. /**
  1200. * qdf_print_clean_node_flag() - Clean up node flag for print control object
  1201. *
  1202. * @idx : Index of print control object
  1203. *
  1204. * Return : None
  1205. */
  1206. void qdf_print_clean_node_flag(unsigned int idx);
  1207. #ifdef DBG_LVL_MAC_FILTERING
  1208. /**
  1209. * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
  1210. *
  1211. * @idx : Index of print control object
  1212. * @enable : Enable/Disable bit sent by callee
  1213. *
  1214. * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
  1215. */
  1216. QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
  1217. uint8_t enable);
  1218. /**
  1219. * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
  1220. *
  1221. * @idx : Index of print control object
  1222. *
  1223. * Return : Flag that indicates enable(1) or disable(0) or invalid(-1)
  1224. */
  1225. bool qdf_print_get_node_flag(unsigned int idx);
  1226. #endif
  1227. /**
  1228. * qdf_logging_init() - Initialize msg logging functionality
  1229. *
  1230. *
  1231. * Return : void
  1232. */
  1233. void qdf_logging_init(void);
  1234. /**
  1235. * qdf_logging_exit() - Cleanup msg logging functionality
  1236. *
  1237. *
  1238. * Return : void
  1239. */
  1240. void qdf_logging_exit(void);
  1241. #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
  1242. /**
  1243. * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
  1244. * @buffer: the string buffer to print into
  1245. * @addr: address of the symbol to lookup and print
  1246. *
  1247. * Return: number of characters printed
  1248. */
  1249. int qdf_sprint_symbol(char *buffer, void *addr);
  1250. #endif /* __QDF_TRACE_H */