qdf_trace.h 45 KB

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