qdf_trace.h 41 KB

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