qdf_trace.h 47 KB

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