qdf_trace.h 40 KB

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