qdf_trace.h 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054
  1. /*
  2. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #if !defined(__QDF_TRACE_H)
  20. #define __QDF_TRACE_H
  21. /**
  22. * DOC: qdf_trace
  23. * QCA driver framework trace APIs
  24. * Trace, logging, and debugging definitions and APIs
  25. */
  26. /* Include Files */
  27. #include <qdf_types.h> /* For QDF_MODULE_ID... */
  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. * 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. * 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. #ifdef CONNECTIVITY_DIAG_EVENT
  157. /**
  158. * enum diag_dp_tx_rx_status - TX/RX packet status
  159. * @DIAG_TX_RX_STATUS_INVALID: default invalid status
  160. * @DIAG_TX_RX_STATUS_OK: successfully sent + acked
  161. * @DIAG_TX_RX_STATUS_FW_DISCARD: queued but not sent over air
  162. * @DIAG_TX_RX_STATUS_NO_ACK: packet sent but no ack received
  163. * @DIAG_TX_RX_STATUS_DROP: packet dropped due to congestion
  164. * @DIAG_TX_RX_STATUS_DOWNLOAD_SUCC: packet delivered to target
  165. * @DIAG_TX_RX_STATUS_DEFAULT: default status
  166. * @DIAG_TX_RX_STATUS_MAX:
  167. */
  168. enum diag_dp_tx_rx_status {
  169. DIAG_TX_RX_STATUS_INVALID,
  170. DIAG_TX_RX_STATUS_OK,
  171. DIAG_TX_RX_STATUS_FW_DISCARD,
  172. DIAG_TX_RX_STATUS_NO_ACK,
  173. DIAG_TX_RX_STATUS_DROP,
  174. DIAG_TX_RX_STATUS_DOWNLOAD_SUCC,
  175. DIAG_TX_RX_STATUS_DEFAULT,
  176. DIAG_TX_RX_STATUS_MAX
  177. };
  178. /**
  179. * enum diag_tx_status - Used by attribute
  180. * @DIAG_TX_STATUS_FAIL: Indicates frame is not sent over the air.
  181. * @DIAG_TX_STATUS_NO_ACK: Indicates packet sent but acknowledgment
  182. * is not received.
  183. * @DIAG_TX_STATUS_ACK: Indicates the frame is successfully sent and
  184. * acknowledged.
  185. */
  186. enum diag_tx_status {
  187. DIAG_TX_STATUS_FAIL = 1,
  188. DIAG_TX_STATUS_NO_ACK = 2,
  189. DIAG_TX_STATUS_ACK = 3
  190. };
  191. /**
  192. * wlan_get_diag_tx_status() - Gives the diag logging specific tx status
  193. * @tx_status: fw specific TX status
  194. *
  195. * Returns TX status specified in enum diag_tx_status
  196. */
  197. enum diag_tx_status wlan_get_diag_tx_status(enum qdf_dp_tx_rx_status tx_status);
  198. #endif
  199. #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
  200. #ifndef MAX_QDF_DP_TRACE_RECORDS
  201. #define MAX_QDF_DP_TRACE_RECORDS 2000
  202. #endif
  203. #define QDF_DP_TRACE_RECORD_SIZE 66 /* bytes */
  204. #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff
  205. #define QDF_DP_TRACE_VERBOSITY_HIGH 4
  206. #define QDF_DP_TRACE_VERBOSITY_MEDIUM 3
  207. #define QDF_DP_TRACE_VERBOSITY_LOW 2
  208. #define QDF_DP_TRACE_VERBOSITY_ULTRA_LOW 1
  209. #define QDF_DP_TRACE_VERBOSITY_BASE 0
  210. /**
  211. * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
  212. * @QDF_DP_TRACE_INVALID: invalid
  213. * @QDF_DP_TRACE_DROP_PACKET_RECORD: record drop packet
  214. * @QDF_DP_TRACE_EAPOL_PACKET_RECORD: record EAPOL packet
  215. * @QDF_DP_TRACE_DHCP_PACKET_RECORD: record DHCP packet
  216. * @QDF_DP_TRACE_ARP_PACKET_RECORD: record ARP packet
  217. * @QDF_DP_TRACE_MGMT_PACKET_RECORD: record MGMT pacekt
  218. * @QDF_DP_TRACE_EVENT_RECORD: record events
  219. * @QDF_DP_TRACE_BASE_VERBOSITY: below this are part of base verbosity
  220. * @QDF_DP_TRACE_ICMP_PACKET_RECORD: record ICMP packet
  221. * @QDF_DP_TRACE_ICMPv6_PACKET_RECORD: record ICMPv6 packet
  222. * @QDF_DP_TRACE_HDD_TX_TIMEOUT: HDD tx timeout
  223. * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: SOFTAP HDD tx timeout
  224. * @QDF_DP_TRACE_TX_CREDIT_RECORD: credit update record
  225. * @QDF_DP_TRACE_ULTRA_LOW_VERBOSITY: Below this is not logged for >4PPS
  226. * @QDF_DP_TRACE_TX_PACKET_RECORD: record 32 bytes of tx pkt at any layer
  227. * @QDF_DP_TRACE_RX_PACKET_RECORD: record 32 bytes of rx pkt at any layer
  228. * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD: record 32 bytes of tx pkt at HDD
  229. * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD: record 32 bytes of rx pkt at HDD
  230. * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD: record data bytes of tx pkt at LI_DP
  231. * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD: record data bytes of rx pkt at LI_DP
  232. * @QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD: tx completion ptr record for
  233. * lithium
  234. * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD: tx completion ptr record
  235. * @QDF_DP_TRACE_LOW_VERBOSITY: below this are part of low verbosity
  236. * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD: HDD layer ptr record
  237. * @QDF_DP_TRACE_TX_PACKET_PTR_RECORD: DP component Tx ptr record
  238. * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD: Lithium DP layer ptr record
  239. * @QDF_DP_TRACE_RX_PACKET_PTR_RECORD: DP component Rx ptr record
  240. * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD: HDD RX record
  241. * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD: CE layer ptr record
  242. * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD: CE fastpath ptr record
  243. * @QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD: CE fastpath error record
  244. * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD: HTT RX record
  245. * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD: HTT RX offload record
  246. * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD: Lithium DP RX record
  247. * @QDF_DP_TRACE_MED_VERBOSITY: below this are part of med verbosity
  248. * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD: tx queue ptr record
  249. * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD: txrx packet ptr record
  250. * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD: txrx fast path record
  251. * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD: htt packet ptr record
  252. * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD: htc packet ptr record
  253. * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD: hif packet ptr record
  254. * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD: txrx packet ptr record
  255. * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD:
  256. * record data bytes of rx null_queue pkt at LI_DP
  257. * @QDF_DP_TRACE_HIGH_VERBOSITY: below this are part of high verbosity
  258. * @QDF_DP_TRACE_MAX: Max enumeration
  259. */
  260. enum QDF_DP_TRACE_ID {
  261. QDF_DP_TRACE_INVALID,
  262. QDF_DP_TRACE_DROP_PACKET_RECORD,
  263. QDF_DP_TRACE_EAPOL_PACKET_RECORD,
  264. QDF_DP_TRACE_DHCP_PACKET_RECORD,
  265. QDF_DP_TRACE_ARP_PACKET_RECORD,
  266. QDF_DP_TRACE_MGMT_PACKET_RECORD,
  267. QDF_DP_TRACE_EVENT_RECORD,
  268. QDF_DP_TRACE_BASE_VERBOSITY,
  269. QDF_DP_TRACE_ICMP_PACKET_RECORD,
  270. QDF_DP_TRACE_ICMPv6_PACKET_RECORD,
  271. QDF_DP_TRACE_HDD_TX_TIMEOUT,
  272. QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
  273. QDF_DP_TRACE_TX_CREDIT_RECORD,
  274. QDF_DP_TRACE_ULTRA_LOW_VERBOSITY,
  275. QDF_DP_TRACE_TX_PACKET_RECORD,
  276. QDF_DP_TRACE_RX_PACKET_RECORD,
  277. QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
  278. QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
  279. QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
  280. QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD,
  281. QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD,
  282. QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
  283. QDF_DP_TRACE_LOW_VERBOSITY,
  284. QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
  285. QDF_DP_TRACE_TX_PACKET_PTR_RECORD,
  286. QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
  287. QDF_DP_TRACE_RX_PACKET_PTR_RECORD,
  288. QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
  289. QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
  290. QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
  291. QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD,
  292. QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
  293. QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
  294. QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD,
  295. QDF_DP_TRACE_MED_VERBOSITY,
  296. QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
  297. QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
  298. QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
  299. QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
  300. QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
  301. QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
  302. QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
  303. QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD,
  304. QDF_DP_TRACE_HIGH_VERBOSITY,
  305. QDF_DP_TRACE_MAX
  306. };
  307. /**
  308. * enum qdf_proto_dir - direction
  309. * @QDF_TX: TX direction
  310. * @QDF_RX: RX direction
  311. * @QDF_NA: not applicable
  312. */
  313. enum qdf_proto_dir {
  314. QDF_TX,
  315. QDF_RX,
  316. QDF_NA
  317. };
  318. /**
  319. * enum QDF_CREDIT_UPDATE_SOURCE - source of credit record
  320. * @QDF_TX_SCHED: Tx scheduler
  321. * @QDF_TX_COMP: TX completion
  322. * @QDF_TX_CREDIT_UPDATE: credit update indication
  323. * @QDF_HTT_ATTACH: HTT attach
  324. * @QDF_TX_HTT_MSG: HTT TX message
  325. */
  326. enum QDF_CREDIT_UPDATE_SOURCE {
  327. QDF_TX_SCHED,
  328. QDF_TX_COMP,
  329. QDF_TX_CREDIT_UPDATE,
  330. QDF_HTT_ATTACH,
  331. QDF_TX_HTT_MSG
  332. };
  333. /**
  334. * enum QDF_CREDIT_OPERATION - operation on credit
  335. * @QDF_CREDIT_INC: credit increment
  336. * @QDF_CREDIT_DEC: credit decrement
  337. * @QDF_CREDIT_ABS: Abosolute credit
  338. * @QDF_OP_NA: Not applicable
  339. */
  340. enum QDF_CREDIT_OPERATION {
  341. QDF_CREDIT_INC,
  342. QDF_CREDIT_DEC,
  343. QDF_CREDIT_ABS,
  344. QDF_OP_NA
  345. };
  346. /**
  347. * struct qdf_dp_trace_ptr_buf - pointer record buffer
  348. * @cookie: cookie value
  349. * @msdu_id: msdu_id
  350. * @status: completion status
  351. */
  352. struct qdf_dp_trace_ptr_buf {
  353. uint64_t cookie;
  354. uint16_t msdu_id;
  355. uint16_t status;
  356. };
  357. /**
  358. * struct qdf_dp_trace_proto_buf - proto packet buffer
  359. * @sa: source address
  360. * @da: destination address
  361. * @vdev_id: vdev id
  362. * @type: packet type
  363. * @subtype: packet subtype
  364. * @dir: direction
  365. * @proto_priv_data: protocol private data
  366. * can be stored in this.
  367. */
  368. struct qdf_dp_trace_proto_buf {
  369. struct qdf_mac_addr sa;
  370. struct qdf_mac_addr da;
  371. uint8_t vdev_id;
  372. uint8_t type;
  373. uint8_t subtype;
  374. uint8_t dir;
  375. /* for ICMP priv data is bit offset 38 to 42
  376. * 38-40 ICMP_ICMP_ID and
  377. * 40-42 ICMP_SEQ_NUM_OFFSET
  378. */
  379. uint32_t proto_priv_data;
  380. };
  381. /**
  382. * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
  383. * @vdev_id: vdev id
  384. * @type: packet type
  385. * @subtype: packet subtype
  386. */
  387. struct qdf_dp_trace_mgmt_buf {
  388. uint8_t vdev_id;
  389. uint8_t type;
  390. uint8_t subtype;
  391. };
  392. /**
  393. * struct qdf_dp_trace_credit_record - tx credit record
  394. * @source: credit record source
  395. * @operation: credit operation
  396. * @delta: delta of credit
  397. * @total_credits: total credit
  398. * @g0_credit: group 0 credit
  399. * @g1_credit: group 1 credit
  400. */
  401. struct qdf_dp_trace_credit_record {
  402. enum QDF_CREDIT_UPDATE_SOURCE source;
  403. enum QDF_CREDIT_OPERATION operation;
  404. int delta;
  405. int total_credits;
  406. int g0_credit;
  407. int g1_credit;
  408. };
  409. /**
  410. * struct qdf_dp_trace_event_buf - event buffer
  411. * @vdev_id: vdev id
  412. * @type: packet type
  413. * @subtype: packet subtype
  414. */
  415. struct qdf_dp_trace_event_buf {
  416. uint8_t vdev_id;
  417. uint8_t type;
  418. uint8_t subtype;
  419. };
  420. /**
  421. * struct qdf_dp_trace_data_buf - nbuf data buffer
  422. * @msdu_id: msdu id
  423. */
  424. struct qdf_dp_trace_data_buf {
  425. uint16_t msdu_id;
  426. };
  427. /**
  428. * struct qdf_dp_trace_record_s - Describes a record in DP trace
  429. * @time: time when it got stored
  430. * @code: Describes the particular event
  431. * @data: buffer to store data
  432. * @size: Length of the valid data stored in this record
  433. * @pid: process id which stored the data in this record
  434. * @pdev_id: pdev associated with the event
  435. */
  436. struct qdf_dp_trace_record_s {
  437. uint64_t time;
  438. uint8_t code;
  439. uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
  440. uint8_t size;
  441. uint32_t pid;
  442. uint8_t pdev_id;
  443. };
  444. /**
  445. * struct s_qdf_dp_trace_data - Parameters to configure/control DP trace
  446. * @head: Position of first record
  447. * @tail: Position of last record
  448. * @num: Current index
  449. * @proto_bitmap: defines which protocol to be traced
  450. * @no_of_record: defines every nth packet to be traced
  451. * @num_records_to_dump: defines number of records to be dumped
  452. * @dump_counter: counter to track number of records dumped
  453. * @verbosity: defines verbosity level
  454. * @ini_conf_verbosity: Configured verbosity from INI
  455. * @enable: enable/disable DP trace
  456. * @count: current packet number
  457. * @live_mode_config: configuration as received during initialization
  458. * @live_mode: current live mode, enabled or disabled, can be throttled based
  459. * on throughput
  460. * @curr_pos:
  461. * @saved_tail:
  462. * @force_live_mode: flag to enable live mode all the time for all packets.
  463. * This can be set/unset from userspace and overrides other
  464. * live mode flags.
  465. * @dynamic_verbosity_modify: Dynamic user configured verbosity overrides all
  466. * @print_pkt_cnt: count of number of packets printed in live mode
  467. * @high_tput_thresh: thresh beyond which live mode is turned off
  468. * @thresh_time_limit: max time, in terms of BW timer intervals to wait,
  469. * for determining if high_tput_thresh has been crossed. ~1s
  470. * @tx_count: tx counter
  471. * @rx_count: rx counter
  472. * @arp_req: stats for arp reqs
  473. * @arp_resp: stats for arp resps
  474. * @icmp_req: stats for icmp reqs
  475. * @icmp_resp: stats for icmp resps
  476. * @dhcp_disc: stats for dhcp discover msgs
  477. * @dhcp_req: stats for dhcp req msgs
  478. * @dhcp_off: stats for dhcp offer msgs
  479. * @dhcp_ack: stats for dhcp ack msgs
  480. * @dhcp_nack: stats for dhcp nack msgs
  481. * @dhcp_others: stats for other dhcp pkts types
  482. * @eapol_m1: stats for eapol m1
  483. * @eapol_m2: stats for eapol m2
  484. * @eapol_m3: stats for eapol m3
  485. * @eapol_m4: stats for eapol m4
  486. * @eapol_others: stats for other eapol pkt types
  487. * @icmpv6_req: stats for icmpv6 reqs
  488. * @icmpv6_resp: stats for icmpv6 resps
  489. * @icmpv6_ns: stats for icmpv6 nss
  490. * @icmpv6_na: stats for icmpv6 nas
  491. * @icmpv6_rs: stats for icmpv6 rss
  492. * @icmpv6_ra: stats for icmpv6 ras
  493. * @proto_event_bitmap: defines which protocol to be diag logged.
  494. * refer QDF_NBUF_PKT_TRAC_TYPE_DNS to QDF_NBUF_PKT_TRAC_TYPE_ARP
  495. * for bitmap.
  496. */
  497. struct s_qdf_dp_trace_data {
  498. uint32_t head;
  499. uint32_t tail;
  500. uint32_t num;
  501. uint32_t proto_bitmap;
  502. uint8_t no_of_record;
  503. uint16_t num_records_to_dump;
  504. uint16_t dump_counter;
  505. uint8_t verbosity;
  506. uint8_t ini_conf_verbosity;
  507. bool enable;
  508. bool live_mode_config;
  509. bool live_mode;
  510. uint32_t curr_pos;
  511. uint32_t saved_tail;
  512. bool force_live_mode;
  513. bool dynamic_verbosity_modify;
  514. uint8_t print_pkt_cnt;
  515. uint8_t high_tput_thresh;
  516. uint16_t thresh_time_limit;
  517. /* Stats */
  518. uint32_t tx_count;
  519. uint32_t rx_count;
  520. u16 arp_req;
  521. u16 arp_resp;
  522. u16 dhcp_disc;
  523. u16 dhcp_req;
  524. u16 dhcp_off;
  525. u16 dhcp_ack;
  526. u16 dhcp_nack;
  527. u16 dhcp_others;
  528. u16 eapol_m1;
  529. u16 eapol_m2;
  530. u16 eapol_m3;
  531. u16 eapol_m4;
  532. u16 eapol_others;
  533. u16 icmp_req;
  534. u16 icmp_resp;
  535. u16 icmpv6_req;
  536. u16 icmpv6_resp;
  537. u16 icmpv6_ns;
  538. u16 icmpv6_na;
  539. u16 icmpv6_rs;
  540. u16 icmpv6_ra;
  541. uint32_t proto_event_bitmap;
  542. };
  543. /**
  544. * enum qdf_dpt_debugfs_state - state to control read to debugfs file
  545. * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID: invalid state
  546. * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT: initial state
  547. * @QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS: read is in progress
  548. * @QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE: read complete
  549. */
  550. enum qdf_dpt_debugfs_state {
  551. QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID,
  552. QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT,
  553. QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS,
  554. QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE,
  555. };
  556. #define QDF_WIFI_MODULE_PARAMS_FILE "wifi_module_param.ini"
  557. typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
  558. typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
  559. #ifdef WLAN_FEATURE_MEMDUMP_ENABLE
  560. /**
  561. * qdf_register_debugcb_init() - initializes debug callbacks
  562. * to NULL
  563. *
  564. * Return: None
  565. */
  566. void qdf_register_debugcb_init(void);
  567. /**
  568. * qdf_register_debug_callback() - stores callback handlers to print
  569. * state information
  570. * @module_id: module id of layer
  571. * @qdf_state_infocb: callback to be registered
  572. *
  573. * This function is used to store callback handlers to print
  574. * state information
  575. *
  576. * Return: None
  577. */
  578. void qdf_register_debug_callback(QDF_MODULE_ID module_id,
  579. tp_qdf_state_info_cb qdf_state_infocb);
  580. /**
  581. * qdf_state_info_dump_all() - it invokes callback of layer which registered
  582. * its callback to print its state information.
  583. * @buf: buffer pointer to be passed
  584. * @size: size of buffer to be filled
  585. * @driver_dump_size: actual size of buffer used
  586. *
  587. * Return: QDF_STATUS_SUCCESS on success
  588. */
  589. QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
  590. uint16_t *driver_dump_size);
  591. #else /* WLAN_FEATURE_MEMDUMP_ENABLE */
  592. static inline void qdf_register_debugcb_init(void)
  593. {
  594. }
  595. #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
  596. #ifdef TRACE_RECORD
  597. /**
  598. * qdf_trace_register() - registers the call back functions
  599. * @module_id: enum value of module
  600. * @qdf_trace_callback: call back functions to display the messages in
  601. * particular format.
  602. *
  603. * Registers the call back functions to display the messages in particular
  604. * format mentioned in these call back functions. This functions should be
  605. * called by interested module in their init part as we will be ready to
  606. * register as soon as modules are up.
  607. *
  608. * Return: None
  609. */
  610. void qdf_trace_register(QDF_MODULE_ID module_id,
  611. tp_qdf_trace_cb qdf_trace_callback);
  612. /**
  613. * qdf_trace_init() - initializes qdf trace structures and variables
  614. *
  615. * Called immediately after cds_preopen, so that we can start recording HDD
  616. * events ASAP.
  617. *
  618. * Return: None
  619. */
  620. void qdf_trace_init(void);
  621. /**
  622. * qdf_trace_deinit() - frees memory allocated dynamically
  623. *
  624. * Called from cds_deinit, so that we can free the memory and resets
  625. * the variables
  626. *
  627. * Return: None
  628. */
  629. void qdf_trace_deinit(void);
  630. /**
  631. * qdf_trace() - puts the messages in to ring-buffer
  632. * @module: Enum of module, basically module id.
  633. * @code: Code to be recorded
  634. * @session: Session ID of the log
  635. * @data: Actual message contents
  636. *
  637. * This function will be called from each module who wants record the messages
  638. * in circular queue. Before calling this functions make sure you have
  639. * registered your module with qdf through qdf_trace_register function.
  640. *
  641. * Return: None
  642. */
  643. void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data);
  644. /**
  645. * qdf_trace_enable() - Enable MTRACE for specific modules
  646. * @bitmask_of_module_id: Bitmask according to enum of the modules.
  647. * 32[dec] = 0010 0000 [bin] <enum of HDD is 5>
  648. * 64[dec] = 0100 0000 [bin] <enum of SME is 6>
  649. * 128[dec] = 1000 0000 [bin] <enum of PE is 7>
  650. * @enable: can be true or false true implies enabling MTRACE false implies
  651. * disabling MTRACE.
  652. *
  653. * Enable MTRACE for specific modules whose bits are set in bitmask and enable
  654. * is true. if enable is false it disables MTRACE for that module. set the
  655. * bitmask according to enum value of the modules.
  656. * This functions will be called when you issue ioctl as mentioned following
  657. * [iwpriv wlan0 setdumplog <value> <enable>].
  658. * <value> - Decimal number, i.e. 64 decimal value shows only SME module,
  659. * 128 decimal value shows only PE module, 192 decimal value shows PE and SME.
  660. *
  661. * Return: None
  662. */
  663. void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable);
  664. /**
  665. * qdf_trace_dump_all() - Dump data from ring buffer via call back functions
  666. * registered with QDF
  667. * @p_mac: Context of particular module
  668. * @code: Reason code
  669. * @session: Session id of log
  670. * @count: Number of lines to dump starting from tail to head
  671. * @bitmask_of_module: Bitmask according to enum of the modules.
  672. *
  673. * This function will be called up on issuing ioctl call as mentioned following
  674. * [iwpriv wlan0 dumplog 0 0 <n> <bitmask_of_module>]
  675. *
  676. * <n> - number lines to dump starting from tail to head.
  677. *
  678. * <bitmask_of_module> - if anybody wants to know how many messages were
  679. * recorded for particular module/s mentioned by setbit in bitmask from last
  680. * <n> messages. It is optional, if you don't provide then it will dump
  681. * everything from buffer.
  682. *
  683. * Return: None
  684. */
  685. void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session,
  686. uint32_t count, uint32_t bitmask_of_module);
  687. /**
  688. * qdf_trace_spin_lock_init() - initializes the lock variable before use
  689. *
  690. * This function will be called from cds_alloc_global_context, we will have lock
  691. * available to use ASAP
  692. *
  693. * Return: None
  694. */
  695. QDF_STATUS qdf_trace_spin_lock_init(void);
  696. #else
  697. #ifndef QDF_TRACE_PRINT_ENABLE
  698. static inline
  699. void qdf_trace_init(void)
  700. {
  701. }
  702. static inline
  703. void qdf_trace_deinit(void)
  704. {
  705. }
  706. static inline
  707. void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable)
  708. {
  709. }
  710. static inline
  711. void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data)
  712. {
  713. }
  714. static inline
  715. void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session,
  716. uint32_t count, uint32_t bitmask_of_module)
  717. {
  718. }
  719. static inline
  720. QDF_STATUS qdf_trace_spin_lock_init(void)
  721. {
  722. return QDF_STATUS_SUCCESS;
  723. }
  724. #endif
  725. #endif
  726. #ifdef WLAN_MAX_LOGS_PER_SEC
  727. /**
  728. * qdf_detected_excessive_logging() - Excessive logging detected
  729. *
  730. * Track logging count using a quasi-tumbling window.
  731. * If the max logging count for a given window is exceeded,
  732. * return true else fails.
  733. *
  734. * Return: true/false
  735. */
  736. bool qdf_detected_excessive_logging(void);
  737. /**
  738. * qdf_rl_print_count_set() - set the ratelimiting print count
  739. * @rl_print_count: ratelimiting print count
  740. *
  741. * Return: none
  742. */
  743. void qdf_rl_print_count_set(uint32_t rl_print_count);
  744. /**
  745. * qdf_rl_print_time_set() - set the ratelimiting print time
  746. * @rl_print_time: ratelimiting print time
  747. *
  748. * Return: none
  749. */
  750. void qdf_rl_print_time_set(uint32_t rl_print_time);
  751. /**
  752. * qdf_rl_print_suppressed_log() - print the suppressed logs count
  753. *
  754. * Return: none
  755. */
  756. void qdf_rl_print_suppressed_log(void);
  757. /**
  758. * qdf_rl_print_suppressed_inc() - increment the suppressed logs count
  759. *
  760. * Return: none
  761. */
  762. void qdf_rl_print_suppressed_inc(void);
  763. #else /* WLAN_MAX_LOGS_PER_SEC */
  764. static inline bool qdf_detected_excessive_logging(void)
  765. {
  766. return false;
  767. }
  768. static inline void qdf_rl_print_count_set(uint32_t rl_print_count) {}
  769. static inline void qdf_rl_print_time_set(uint32_t rl_print_time) {}
  770. static inline void qdf_rl_print_suppressed_log(void) {}
  771. static inline void qdf_rl_print_suppressed_inc(void) {}
  772. #endif /* WLAN_MAX_LOGS_PER_SEC */
  773. #ifdef ENABLE_MTRACE_LOG
  774. /**
  775. * qdf_mtrace_log() - Logs a message tracepoint to DIAG
  776. * Infrastructure.
  777. * @src_module: Enum of source module (basically module id)
  778. * from where the message with message_id is posted.
  779. * @dst_module: Enum of destination module (basically module id)
  780. * to which the message with message_id is posted.
  781. * @message_id: Id of the message to be posted
  782. * @vdev_id: Vdev Id
  783. *
  784. * This function logs to the DIAG Infrastructure a tracepoint for a
  785. * message being sent from a source module to a destination module
  786. * with a specific ID for the benefit of a specific vdev.
  787. * For non-vdev messages vdev_id will be NO_SESSION
  788. * Return: None
  789. */
  790. void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  791. uint16_t message_id, uint8_t vdev_id);
  792. #else
  793. static inline
  794. void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  795. uint16_t message_id, uint8_t vdev_id)
  796. {
  797. }
  798. #endif
  799. #ifdef TRACE_RECORD
  800. /**
  801. * qdf_mtrace() - puts the messages in to ring-buffer
  802. * and logs a message tracepoint to DIAG Infrastructure.
  803. * @src_module: Enum of source module (basically module id)
  804. * from where the message with message_id is posted.
  805. * @dst_module: Enum of destination module (basically module id)
  806. * to which the message with message_id is posted.
  807. * @message_id: Id of the message to be posted
  808. * @vdev_id: Vdev Id
  809. * @data: Actual message contents
  810. *
  811. * This function will be called from each module which wants to record the
  812. * messages in circular queue. Before calling this function make sure you
  813. * have registered your module with qdf through qdf_trace_register function.
  814. * In addition of the recording the messages in circular queue this function
  815. * will log the message tracepoint to the DIAG infrastructure.
  816. * these logs will be later used by post processing script.
  817. *
  818. * Return: None
  819. */
  820. void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  821. uint16_t message_id, uint8_t vdev_id, uint32_t data);
  822. #else
  823. static inline
  824. void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module,
  825. uint16_t message_id, uint8_t vdev_id, uint32_t data)
  826. {
  827. }
  828. #endif
  829. #ifdef CONFIG_DP_TRACE
  830. /**
  831. * qdf_dp_set_proto_bitmap() - set dp trace proto bitmap
  832. * @val: unsigned bitmap to set
  833. *
  834. * Return: proto bitmap
  835. */
  836. void qdf_dp_set_proto_bitmap(uint32_t val);
  837. /**
  838. * qdf_dp_trace_set_verbosity() - set verbosity value
  839. * @val: Value to set
  840. *
  841. * Return: Null
  842. */
  843. void qdf_dp_trace_set_verbosity(uint32_t val);
  844. /**
  845. * qdf_dp_set_no_of_record() - set dp trace no_of_record
  846. * @val: unsigned no_of_record to set
  847. *
  848. * Return: null
  849. */
  850. void qdf_dp_set_no_of_record(uint32_t val);
  851. #define QDF_DP_TRACE_RECORD_INFO_LIVE (0x1)
  852. #define QDF_DP_TRACE_RECORD_INFO_THROTTLED (0x1 << 1)
  853. /**
  854. * qdf_dp_trace_log_pkt() - log packet type enabled through iwpriv
  855. * @vdev_id: vdev_id
  856. * @skb: skb pointer
  857. * @dir: direction
  858. * @pdev_id: pdev_id
  859. * @op_mode: Vdev Operation mode
  860. *
  861. * Return: true: some protocol was logged, false: no protocol was logged.
  862. */
  863. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  864. enum qdf_proto_dir dir, uint8_t pdev_id,
  865. enum QDF_OPMODE op_mode);
  866. /**
  867. * qdf_dp_trace_init() - enables the DP trace
  868. * @live_mode_config: live mode configuration
  869. * @thresh: high throughput threshold for disabling live mode
  870. * @time_limit: max time to wait before deciding if thresh is crossed
  871. * @verbosity: dptrace verbosity level
  872. * @proto_bitmap: bitmap to enable/disable specific protocols
  873. *
  874. * Called during driver load to init dptrace
  875. *
  876. * A brief note on the 'thresh' param -
  877. * Total # of packets received in a bandwidth timer interval beyond which
  878. * DP Trace logging for data packets (including ICMP) will be disabled.
  879. * In memory logging will still continue for these packets. Other packets for
  880. * which proto.bitmap is set will continue to be recorded in logs and in memory.
  881. *
  882. * Return: None
  883. */
  884. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  885. uint16_t time_limit, uint8_t verbosity,
  886. uint32_t proto_bitmap);
  887. void qdf_dp_trace_deinit(void);
  888. /**
  889. * qdf_dp_trace_spin_lock_init() - initializes the lock variable before use
  890. * This function will be called from cds_alloc_global_context, we will have lock
  891. * available to use ASAP
  892. *
  893. * Return: None
  894. */
  895. void qdf_dp_trace_spin_lock_init(void);
  896. /**
  897. * qdf_dp_trace_set_value() - Configure the value to control DP trace
  898. * @proto_bitmap: defines the protocol to be tracked
  899. * @no_of_records: defines the nth packet which is traced
  900. * @verbosity: defines the verbosity level
  901. *
  902. * Return: None
  903. */
  904. void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records,
  905. uint8_t verbosity);
  906. /**
  907. * qdf_dp_trace_set_track() - Marks whether the packet needs to be traced
  908. * @nbuf: defines the netbuf
  909. * @dir: direction
  910. *
  911. * Return: None
  912. */
  913. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
  914. /**
  915. * qdf_dp_trace() - Stores the data in buffer
  916. * @nbuf: defines the netbuf
  917. * @code: defines the event
  918. * @pdev_id: pdev_id
  919. * @data: defines the data to be stored
  920. * @size: defines the size of the data record
  921. * @dir: direction
  922. *
  923. * Return: None
  924. */
  925. void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
  926. uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
  927. /**
  928. * qdf_dp_trace_dump_all() - Dump data from ring buffer via call back functions
  929. * registered with QDF
  930. * @count: Number of lines to dump starting from tail to head
  931. * @pdev_id: pdev_id
  932. *
  933. * Return: None
  934. */
  935. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
  936. /**
  937. * qdf_dpt_get_curr_pos_debugfs() - get curr position to start read
  938. * @file: debugfs file to read
  939. * @state: state to control read to debugfs file
  940. *
  941. * Return: curr pos
  942. */
  943. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  944. enum qdf_dpt_debugfs_state state);
  945. /**
  946. * qdf_dpt_dump_stats_debugfs() - dump DP Trace stats to debugfs file
  947. * @file: debugfs file to read
  948. * @curr_pos: curr position to start read
  949. *
  950. * Return: QDF_STATUS
  951. */
  952. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  953. uint32_t curr_pos);
  954. /**
  955. * qdf_dpt_set_value_debugfs() - set value of DP Trace debugfs params
  956. * @proto_bitmap: defines which protocol to be traced
  957. * @no_of_record: defines every nth packet to be traced
  958. * @verbosity: defines verbosity level
  959. * @num_records_to_dump: defines number of records to be dumped
  960. *
  961. * Return: none
  962. */
  963. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  964. uint8_t verbosity, uint16_t num_records_to_dump);
  965. /**
  966. * qdf_dp_trace_dump_stats() - dump DP Trace stats
  967. *
  968. * Return: none
  969. */
  970. void qdf_dp_trace_dump_stats(void);
  971. typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
  972. uint16_t, uint8_t, uint8_t info);
  973. /**
  974. * qdf_dp_display_record() - Displays a record in DP trace
  975. * @record: pointer to a record in DP trace
  976. * @index: record index
  977. * @pdev_id: pdev id for the mgmt pkt
  978. * @info: info used to display pkt (live mode, throttling)
  979. *
  980. * Return: None
  981. */
  982. void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
  983. uint16_t index, uint8_t pdev_id,
  984. uint8_t info);
  985. /**
  986. * qdf_dp_display_ptr_record() - display record
  987. * @record: dptrace record
  988. * @rec_index: index
  989. * @pdev_id: pdev id for the mgmt pkt
  990. * @info: info used to display pkt (live mode, throttling)
  991. *
  992. * Return: none
  993. */
  994. void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record,
  995. uint16_t rec_index, uint8_t pdev_id,
  996. uint8_t info);
  997. /**
  998. * qdf_dp_display_proto_pkt() - display proto packet
  999. * @record: dptrace record
  1000. * @index: index
  1001. * @pdev_id: pdev id for the mgmt pkt
  1002. * @info: info used to display pkt (live mode, throttling)
  1003. *
  1004. * Return: none
  1005. */
  1006. void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
  1007. uint16_t index, uint8_t pdev_id,
  1008. uint8_t info);
  1009. /**
  1010. * qdf_dp_display_data_pkt_record() - Displays a data packet in DP trace
  1011. * @record: pointer to a record in DP trace
  1012. * @rec_index: record index
  1013. * @pdev_id: pdev id
  1014. * @info: display info regarding record
  1015. *
  1016. * Return: None
  1017. */
  1018. void
  1019. qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record,
  1020. uint16_t rec_index, uint8_t pdev_id,
  1021. uint8_t info);
  1022. /**
  1023. * qdf_dp_get_status_from_htt() - Convert htt tx status to qdf dp status
  1024. * @status: htt_tx_status which needs to be converted
  1025. *
  1026. * Return: the status that from qdf_dp_tx_rx_status
  1027. */
  1028. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status);
  1029. /**
  1030. * qdf_dp_get_status_from_a_status() - Convert A_STATUS to qdf dp status
  1031. * @status: A_STATUS which needs to be converted
  1032. *
  1033. * Return: the status that from qdf_dp_tx_rx_status
  1034. */
  1035. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status);
  1036. /**
  1037. * qdf_dp_trace_ptr() - record dptrace
  1038. * @nbuf: network buffer
  1039. * @code: dptrace code
  1040. * @pdev_id: pdev_id
  1041. * @data: data
  1042. * @size: size of data
  1043. * @msdu_id: msdu_id
  1044. * @buf_arg_status: return status
  1045. * @qdf_tx_status: qdf tx rx status
  1046. * @op_mode: Vdev Operation mode
  1047. *
  1048. * Return: none
  1049. */
  1050. void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  1051. uint8_t pdev_id, uint8_t *data, uint8_t size,
  1052. uint16_t msdu_id, uint16_t buf_arg_status,
  1053. enum qdf_dp_tx_rx_status qdf_tx_status,
  1054. enum QDF_OPMODE op_mode);
  1055. /**
  1056. * qdf_dp_trace_throttle_live_mode() - Throttle DP Trace live mode
  1057. * @high_bw_request: whether this is a high BW req or not
  1058. *
  1059. * The function tries to prevent excessive logging into the live buffer by
  1060. * having an upper limit on number of packets that can be logged per second.
  1061. *
  1062. * The intention is to allow occasional pings and data packets and really low
  1063. * throughput levels while suppressing bursts and higher throughput levels so
  1064. * that we donot hog the live buffer.
  1065. *
  1066. * If the number of packets printed in a particular second exceeds the thresh,
  1067. * disable printing in the next second.
  1068. *
  1069. * Return: None
  1070. */
  1071. void qdf_dp_trace_throttle_live_mode(bool high_bw_request);
  1072. /**
  1073. * qdf_dp_trace_apply_tput_policy() - Change verbosity based on the TPUT
  1074. * @is_data_traffic: Is traffic more than low TPUT threashould
  1075. *
  1076. * Return: None
  1077. */
  1078. void qdf_dp_trace_apply_tput_policy(bool is_data_traffic);
  1079. /**
  1080. * qdf_dp_trace_data_pkt() - trace data packet
  1081. * @nbuf: nbuf which needs to be traced
  1082. * @pdev_id: pdev_id
  1083. * @code: QDF_DP_TRACE_ID for the packet (TX or RX)
  1084. * @msdu_id: tx desc id for the nbuf (Only applies to TX packets)
  1085. * @dir: TX or RX packet direction
  1086. *
  1087. * Return: None
  1088. */
  1089. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  1090. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  1091. enum qdf_proto_dir dir);
  1092. /**
  1093. * qdf_dp_get_proto_bitmap() - get dp trace proto bitmap
  1094. *
  1095. * Return: proto bitmap
  1096. */
  1097. uint32_t qdf_dp_get_proto_bitmap(void);
  1098. uint8_t qdf_dp_get_verbosity(void);
  1099. /**
  1100. * qdf_dp_get_no_of_record() - get dp trace no_of_record
  1101. *
  1102. * Return: number of records
  1103. */
  1104. uint8_t qdf_dp_get_no_of_record(void);
  1105. /**
  1106. * qdf_dp_trace_proto_pkt() - record proto packet
  1107. * @code: dptrace code
  1108. * @vdev_id: vdev id
  1109. * @sa: source mac address
  1110. * @da: destination mac address
  1111. * @type: proto type
  1112. * @subtype: proto subtype
  1113. * @dir: direction
  1114. * @pdev_id: pdev id
  1115. * @print: to print this proto pkt or not
  1116. * @proto_priv_data: protocol specific private
  1117. * data.
  1118. * Return: none
  1119. */
  1120. void
  1121. qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1122. uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
  1123. enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
  1124. uint8_t pdev_id, bool print, uint32_t proto_priv_data);
  1125. /**
  1126. * qdf_dp_trace_disable_live_mode() - disable live mode for dptrace
  1127. *
  1128. * Return: none
  1129. */
  1130. void qdf_dp_trace_disable_live_mode(void);
  1131. /**
  1132. * qdf_dp_trace_enable_live_mode() - enable live mode for dptrace
  1133. *
  1134. * Return: none
  1135. */
  1136. void qdf_dp_trace_enable_live_mode(void);
  1137. /**
  1138. * qdf_dp_trace_clear_buffer() - clear dp trace buffer
  1139. *
  1140. * Return: none
  1141. */
  1142. void qdf_dp_trace_clear_buffer(void);
  1143. /**
  1144. * qdf_dp_trace_mgmt_pkt() - record mgmt packet
  1145. * @code: dptrace code
  1146. * @vdev_id: vdev id
  1147. * @pdev_id: pdev_id
  1148. * @type: proto type
  1149. * @subtype: proto subtype
  1150. *
  1151. * Return: none
  1152. */
  1153. void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1154. uint8_t pdev_id, enum qdf_proto_type type,
  1155. enum qdf_proto_subtype subtype);
  1156. /**
  1157. * qdf_dp_trace_credit_record() - record credit update
  1158. * @source: source of record
  1159. * @operation: credit operation
  1160. * @delta: credit delta
  1161. * @total_credits: total credit
  1162. * @g0_credit: group 0 credit
  1163. * @g1_credit: group 1 credit
  1164. */
  1165. void qdf_dp_trace_credit_record(enum QDF_CREDIT_UPDATE_SOURCE source,
  1166. enum QDF_CREDIT_OPERATION operation,
  1167. int delta, int total_credits,
  1168. int g0_credit, int g1_credit);
  1169. /**
  1170. * qdf_dp_display_mgmt_pkt() - display proto packet
  1171. * @record: dptrace record
  1172. * @index: index
  1173. * @pdev_id: pdev id for the mgmt pkt
  1174. * @info: info used to display pkt (live mode, throttling)
  1175. *
  1176. * Return: none
  1177. */
  1178. void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
  1179. uint16_t index, uint8_t pdev_id, uint8_t info);
  1180. /**
  1181. * qdf_dp_display_credit_record() - display credit record
  1182. * @record: dptrace record
  1183. * @index: index
  1184. * @pdev_id: pdev id
  1185. * @info: metadeta info
  1186. */
  1187. void qdf_dp_display_credit_record(struct qdf_dp_trace_record_s *record,
  1188. uint16_t index, uint8_t pdev_id,
  1189. uint8_t info);
  1190. /**
  1191. * qdf_dp_display_event_record() - display event records
  1192. * @record: dptrace record
  1193. * @index: index
  1194. * @pdev_id: pdev id for the mgmt pkt
  1195. * @info: info used to display pkt (live mode, throttling)
  1196. *
  1197. * Return: none
  1198. */
  1199. void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
  1200. uint16_t index, uint8_t pdev_id, uint8_t info);
  1201. /**
  1202. * qdf_dp_trace_record_event() - record events
  1203. * @code: dptrace code
  1204. * @vdev_id: vdev id
  1205. * @pdev_id: pdev_id
  1206. * @type: proto type
  1207. * @subtype: proto subtype
  1208. *
  1209. * Return: none
  1210. */
  1211. void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1212. uint8_t pdev_id, enum qdf_proto_type type,
  1213. enum qdf_proto_subtype subtype);
  1214. /**
  1215. * qdf_dp_set_proto_event_bitmap() - Set the protocol event bitmap
  1216. * @value: proto event bitmap value.
  1217. *
  1218. * QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01
  1219. * QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  1220. * QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  1221. * QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  1222. *
  1223. * Return: none
  1224. */
  1225. void qdf_dp_set_proto_event_bitmap(uint32_t value);
  1226. /**
  1227. * qdf_dp_log_proto_pkt_info() - Send diag log event
  1228. * @sa: source MAC address
  1229. * @da: destination MAC address
  1230. * @type: pkt type
  1231. * @subtype: pkt subtype
  1232. * @dir: tx or rx
  1233. * @msdu_id: msdu id
  1234. * @status: status
  1235. *
  1236. * Return: none
  1237. */
  1238. void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type,
  1239. uint8_t subtype, uint8_t dir, uint16_t msdu_id,
  1240. uint8_t status);
  1241. /**
  1242. * qdf_dp_track_noack_check() - Check if no ack count should be tracked for
  1243. * the configured protocol packet types
  1244. * @nbuf: nbuf
  1245. * @subtype: subtype of packet to be tracked
  1246. *
  1247. * Return: none
  1248. */
  1249. void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype);
  1250. #else
  1251. static inline
  1252. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  1253. enum qdf_proto_dir dir, uint8_t pdev_id,
  1254. enum QDF_OPMODE op_mode)
  1255. {
  1256. return false;
  1257. }
  1258. static inline
  1259. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  1260. uint16_t time_limit, uint8_t verbosity,
  1261. uint32_t proto_bitmap)
  1262. {
  1263. }
  1264. static inline
  1265. void qdf_dp_trace_deinit(void)
  1266. {
  1267. }
  1268. static inline
  1269. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
  1270. {
  1271. }
  1272. static inline
  1273. void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records,
  1274. uint8_t verbosity)
  1275. {
  1276. }
  1277. static inline
  1278. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
  1279. {
  1280. }
  1281. static inline
  1282. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  1283. enum qdf_dpt_debugfs_state state)
  1284. {
  1285. return 0;
  1286. }
  1287. static inline
  1288. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  1289. uint32_t curr_pos)
  1290. {
  1291. return QDF_STATUS_SUCCESS;
  1292. }
  1293. static inline
  1294. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  1295. uint8_t verbosity, uint16_t num_records_to_dump)
  1296. {
  1297. }
  1298. static inline void qdf_dp_trace_dump_stats(void)
  1299. {
  1300. }
  1301. static inline
  1302. void qdf_dp_trace_disable_live_mode(void)
  1303. {
  1304. }
  1305. static inline
  1306. void qdf_dp_trace_enable_live_mode(void)
  1307. {
  1308. }
  1309. static inline
  1310. void qdf_dp_trace_throttle_live_mode(bool high_bw_request)
  1311. {
  1312. }
  1313. static inline
  1314. void qdf_dp_trace_clear_buffer(void)
  1315. {
  1316. }
  1317. static inline
  1318. void qdf_dp_trace_apply_tput_policy(bool is_data_traffic)
  1319. {
  1320. }
  1321. static inline
  1322. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  1323. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  1324. enum qdf_proto_dir dir)
  1325. {
  1326. }
  1327. static inline
  1328. void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type,
  1329. uint8_t subtype, uint8_t dir, uint16_t msdu_id,
  1330. uint8_t status)
  1331. {
  1332. }
  1333. static inline
  1334. void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype)
  1335. {
  1336. }
  1337. static inline
  1338. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status)
  1339. {
  1340. return QDF_TX_RX_STATUS_OK;
  1341. }
  1342. static inline
  1343. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status)
  1344. {
  1345. return QDF_TX_RX_STATUS_OK;
  1346. }
  1347. #endif
  1348. /**
  1349. * qdf_trace_display() - Display trace
  1350. *
  1351. * Return: None
  1352. */
  1353. void qdf_trace_display(void);
  1354. /**
  1355. * qdf_snprintf() - wrapper function to snprintf
  1356. * @str_buffer: string Buffer
  1357. * @size: defines the size of the data record
  1358. * @str_format: Format string in which the message to be logged. This format
  1359. * string contains printf-like replacement parameters, which follow
  1360. * this parameter in the variable argument list.
  1361. *
  1362. * Return: num of bytes written to buffer
  1363. */
  1364. int __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
  1365. char *str_format, ...);
  1366. #define QDF_SNPRINTF qdf_snprintf
  1367. #ifdef TSOSEG_DEBUG
  1368. static inline void qdf_tso_seg_dbg_bug(char *msg)
  1369. {
  1370. qdf_print("%s", msg);
  1371. QDF_BUG(0);
  1372. };
  1373. /**
  1374. * qdf_tso_seg_dbg_init - initialize TSO segment debug structure
  1375. * @tsoseg: structure to initialize
  1376. *
  1377. * TSO segment dbg structures are attached to qdf_tso_seg_elem_t
  1378. * structures and are allocated only of TSOSEG_DEBUG is defined.
  1379. * When allocated, at the time of the tso_seg_pool initialization,
  1380. * which goes with tx_desc initialization (1:1), each structure holds
  1381. * a number of (currently 16) history entries, basically describing
  1382. * what operation has been performed on this particular tso_seg_elem.
  1383. * This history buffer is a circular buffer and the current index is
  1384. * held in an atomic variable called cur. It is incremented every
  1385. * operation. Each of these operations are added with the function
  1386. * qdf_tso_seg_dbg_record.
  1387. * For each segment, this initialization function MUST be called PRIOR
  1388. * TO any _dbg_record() function calls.
  1389. * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero)
  1390. * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element.
  1391. *
  1392. * Return:
  1393. * None
  1394. */
  1395. static inline
  1396. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  1397. {
  1398. tsoseg->dbg.txdesc = NULL;
  1399. qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */
  1400. }
  1401. /**
  1402. * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure
  1403. * @tsoseg: structure to initialize
  1404. * @id: operation ID (identifies the caller)
  1405. *
  1406. * Adds a history entry to the history circular buffer. Each entry
  1407. * contains an operation id (caller, as currently each ID is used only
  1408. * once in the source, so it directly identifies the src line that invoked
  1409. * the recording.
  1410. *
  1411. * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized
  1412. * by qdf_tso_seg_dbg_init.
  1413. *
  1414. * The entry to be added is written at the location pointed by the atomic
  1415. * variable called cur. Cur is an ever increasing atomic variable. It is
  1416. * masked so that only the lower 4 bits are used (16 history entries).
  1417. *
  1418. * Return:
  1419. * int: the entry this record was recorded at
  1420. */
  1421. static inline
  1422. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  1423. {
  1424. int rc = -1;
  1425. unsigned int c;
  1426. qdf_assert(tsoseg);
  1427. if (id == TSOSEG_LOC_ALLOC) {
  1428. c = qdf_atomic_read(&tsoseg->dbg.cur);
  1429. /* dont crash on the very first alloc on the segment */
  1430. c &= 0x0f;
  1431. /* allow only INIT and FREE ops before ALLOC */
  1432. if (tsoseg->dbg.h[c].id >= id)
  1433. qdf_tso_seg_dbg_bug("Rogue TSO seg alloc");
  1434. }
  1435. c = qdf_atomic_inc_return(&tsoseg->dbg.cur);
  1436. c &= 0x0f;
  1437. tsoseg->dbg.h[c].ts = qdf_get_log_timestamp();
  1438. tsoseg->dbg.h[c].id = id;
  1439. rc = c;
  1440. return rc;
  1441. };
  1442. static inline void
  1443. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  1444. {
  1445. if (tsoseg)
  1446. tsoseg->dbg.txdesc = owner;
  1447. };
  1448. static inline void
  1449. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  1450. {
  1451. memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
  1452. return;
  1453. };
  1454. #else
  1455. static inline
  1456. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  1457. {
  1458. };
  1459. static inline
  1460. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  1461. {
  1462. return 0;
  1463. };
  1464. static inline void qdf_tso_seg_dbg_bug(char *msg)
  1465. {
  1466. };
  1467. static inline void
  1468. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  1469. {
  1470. };
  1471. static inline int
  1472. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  1473. {
  1474. memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
  1475. return 0;
  1476. };
  1477. #endif /* TSOSEG_DEBUG */
  1478. /**
  1479. * qdf_trace_hex_dump() - externally called hex dump function
  1480. * @module: Module identifier a member of the QDF_MODULE_ID enumeration that
  1481. * identifies the module issuing the trace message.
  1482. * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating
  1483. * the severity of the condition causing the trace message to be
  1484. * issued. More severe conditions are more likely to be logged.
  1485. * @data: The base address of the buffer to be logged.
  1486. * @buf_len: The size of the buffer to be logged.
  1487. *
  1488. * Checks the level of severity and accordingly prints the trace messages
  1489. *
  1490. * Return: None
  1491. */
  1492. void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  1493. void *data, int buf_len);
  1494. /**
  1495. * qdf_trace_hex_ascii_dump() - externally called hex and ascii dump function
  1496. * @module: Module identifier a member of the QDF_MODULE_ID enumeration that
  1497. * identifies the module issuing the trace message.
  1498. * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating
  1499. * the severity of the condition causing the trace message to be
  1500. * issued. More severe conditions are more likely to be logged.
  1501. * @data: The base address of the buffer to be logged.
  1502. * @buf_len: The size of the buffer to be logged.
  1503. *
  1504. * Checks the level of severity and accordingly prints the trace messages
  1505. *
  1506. * Return: None
  1507. */
  1508. void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  1509. void *data, int buf_len);
  1510. #define ERROR_CODE -1
  1511. #define QDF_MAX_NAME_SIZE 32
  1512. #define MAX_PRINT_CONFIG_SUPPORTED 32
  1513. #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
  1514. /**
  1515. * qdf_set_pidx() - Sets the global qdf_pidx.
  1516. * @pidx: Index of print control object assigned to the module
  1517. *
  1518. */
  1519. void qdf_set_pidx(int pidx);
  1520. /**
  1521. * qdf_get_pidx() - Returns the global qdf_pidx.
  1522. *
  1523. * Return: Current qdf print index.
  1524. */
  1525. int qdf_get_pidx(void);
  1526. /*
  1527. * Shared print control index
  1528. * for converged debug framework
  1529. */
  1530. #define QDF_PRINT_IDX_SHARED -1
  1531. /**
  1532. * QDF_PRINT_INFO() - Generic wrapper API for logging
  1533. * @idx: Index of print control object
  1534. * @module: Module identifier. A member of QDF_MODULE_ID enumeration that
  1535. * identifies the module issuing the trace message
  1536. * @level: Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
  1537. * the severity of the condition causing the trace message to be
  1538. * issued.
  1539. * @str_format: Format string that contains the message to be logged.
  1540. *
  1541. *
  1542. * This wrapper will be used for any generic logging messages. Wrapper will
  1543. * compile a call to converged QDF trace message API.
  1544. *
  1545. * Return: Nothing
  1546. *
  1547. */
  1548. void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
  1549. QDF_TRACE_LEVEL level,
  1550. char *str_format, ...);
  1551. /**
  1552. * struct category_info - Category information structure
  1553. * @category_verbose_mask: Embeds information about category's verbose level
  1554. */
  1555. struct category_info {
  1556. uint16_t category_verbose_mask;
  1557. };
  1558. /**
  1559. * struct category_name_info - Category name information structure
  1560. * @category_name_str: Embeds information about category name
  1561. */
  1562. struct category_name_info {
  1563. unsigned char category_name_str[QDF_MAX_NAME_SIZE];
  1564. };
  1565. /**
  1566. * qdf_trace_msg_cmn() - Converged logging API
  1567. * @idx: Index of print control object assigned to the module
  1568. * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
  1569. * that identifies the category issuing the trace message.
  1570. * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
  1571. * indicating the severity of the condition causing the trace
  1572. * message to be issued. More severe conditions are more likely
  1573. * to be logged.
  1574. * @str_format: Format string. The message to be logged. This format string
  1575. * contains printf-like replacement parameters, which follow this
  1576. * parameter in the variable argument list.
  1577. * @val: Variable argument list part of the log message
  1578. *
  1579. * Return: nothing
  1580. *
  1581. */
  1582. void qdf_trace_msg_cmn(unsigned int idx,
  1583. QDF_MODULE_ID category,
  1584. QDF_TRACE_LEVEL verbose,
  1585. const char *str_format,
  1586. va_list val);
  1587. /**
  1588. * struct qdf_print_ctrl - QDF Print Control structure
  1589. * Statically allocated objects of print control
  1590. * structure are declared that will support maximum of
  1591. * 32 print control objects. Any module that needs to
  1592. * register to the print control framework needs to
  1593. * obtain a print control object using
  1594. * qdf_print_ctrl_register API. It will have to pass
  1595. * pointer to category info structure, name and
  1596. * custom print function to be used if required.
  1597. * @name: Optional name for the control object
  1598. * @cat_info: Array of category_info struct
  1599. * @custom_print: Custom print handler
  1600. * @custom_ctxt: Custom print context
  1601. * @dbglvlmac_on: Flag to enable/disable MAC level filtering
  1602. * @in_use: Boolean to indicate if control object is in use
  1603. */
  1604. struct qdf_print_ctrl {
  1605. char name[QDF_MAX_NAME_SIZE];
  1606. struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
  1607. void (*custom_print)(void *ctxt, const char *fmt, va_list args);
  1608. void *custom_ctxt;
  1609. #ifdef DBG_LVL_MAC_FILTERING
  1610. unsigned char dbglvlmac_on;
  1611. #endif
  1612. bool in_use;
  1613. };
  1614. /**
  1615. * qdf_print_ctrl_register() - Allocate QDF print control object, assign
  1616. * pointer to category info or print control
  1617. * structure and return the index to the callee
  1618. * @cinfo: Pointer to array of category info structure
  1619. * @custom_print_handler: Pointer to custom print handler
  1620. * @custom_ctx: Pointer to custom context
  1621. * @pctrl_name: Pointer to print control object name
  1622. *
  1623. * Return: Index of qdf_print_ctrl structure
  1624. *
  1625. */
  1626. int qdf_print_ctrl_register(const struct category_info *cinfo,
  1627. void *custom_print_handler,
  1628. void *custom_ctx,
  1629. const char *pctrl_name);
  1630. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  1631. /**
  1632. * qdf_initialize_module_param_from_ini() - Update qdf module params
  1633. *
  1634. * Read the file which has wifi module params, parse and update
  1635. * qdf module params.
  1636. *
  1637. * Return: void
  1638. */
  1639. void qdf_initialize_module_param_from_ini(void);
  1640. #else
  1641. static inline
  1642. void qdf_initialize_module_param_from_ini(void)
  1643. {
  1644. }
  1645. #endif
  1646. /**
  1647. * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
  1648. * all categories set to the default level
  1649. *
  1650. * Return: void
  1651. *
  1652. */
  1653. void qdf_shared_print_ctrl_init(void);
  1654. /**
  1655. * qdf_print_setup() - Setup default values to all the print control objects
  1656. *
  1657. * Register new print control object for the callee
  1658. *
  1659. * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
  1660. * on failure
  1661. */
  1662. QDF_STATUS qdf_print_setup(void);
  1663. /**
  1664. * qdf_print_ctrl_cleanup() - Clean up a print control object
  1665. * @idx: Index of print control object
  1666. *
  1667. * Cleanup the print control object for the callee
  1668. *
  1669. * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
  1670. */
  1671. QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
  1672. /**
  1673. * qdf_shared_print_ctrl_cleanup() - Clean up of the shared object
  1674. *
  1675. * Cleanup the shared print-ctrl-object
  1676. *
  1677. * Return: void
  1678. */
  1679. void qdf_shared_print_ctrl_cleanup(void);
  1680. /**
  1681. * qdf_print_set_category_verbose() - Enable/Disable category for a
  1682. * print control object with
  1683. * user provided verbose level
  1684. * @idx: Index of the print control object assigned to callee
  1685. * @category: Category information
  1686. * @verbose: Verbose information
  1687. * @is_set: Flag indicating if verbose level needs to be enabled or disabled
  1688. *
  1689. * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1690. */
  1691. QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
  1692. QDF_MODULE_ID category,
  1693. QDF_TRACE_LEVEL verbose,
  1694. bool is_set);
  1695. /**
  1696. * qdf_log_dump_at_kernel_level() - Enable/Disable printk call
  1697. * @enable: Indicates whether printk is enabled in QDF_TRACE
  1698. *
  1699. * Return: void
  1700. */
  1701. void qdf_log_dump_at_kernel_level(bool enable);
  1702. /**
  1703. * qdf_logging_set_flush_timer() - Set the time period in which host logs
  1704. * should be flushed out to user-space
  1705. * @milliseconds: milliseconds after which the logs should be flushed out to
  1706. * user-space
  1707. *
  1708. * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1709. */
  1710. int qdf_logging_set_flush_timer(uint32_t milliseconds);
  1711. /**
  1712. * qdf_logging_flush_logs() - Flush out the logs to user-space one time
  1713. *
  1714. * Return: void
  1715. */
  1716. void qdf_logging_flush_logs(void);
  1717. /**
  1718. * qdf_print_get_category_verbose() - Get category verbose information for the
  1719. * print control object
  1720. *
  1721. * @idx: Index of print control object
  1722. * @category: Category information
  1723. *
  1724. * Return: Verbose value for the particular category
  1725. */
  1726. QDF_TRACE_LEVEL qdf_print_get_category_verbose(unsigned int idx,
  1727. QDF_MODULE_ID category);
  1728. /**
  1729. * qdf_print_is_category_enabled() - Get category information for the
  1730. * print control object
  1731. *
  1732. * @idx: Index of print control object
  1733. * @category: Category information
  1734. *
  1735. * Return: Verbose enabled(true) or disabled(false) or invalid input (false)
  1736. */
  1737. bool qdf_print_is_category_enabled(unsigned int idx,
  1738. QDF_MODULE_ID category);
  1739. /**
  1740. * qdf_print_is_verbose_enabled() - Get verbose information of a category for
  1741. * the print control object
  1742. *
  1743. * @idx: Index of print control object
  1744. * @category: Category information
  1745. * @verbose: Verbose information
  1746. *
  1747. * Return: Verbose enabled(true) or disabled(false) or invalid input (false)
  1748. */
  1749. bool qdf_print_is_verbose_enabled(unsigned int idx,
  1750. QDF_MODULE_ID category,
  1751. QDF_TRACE_LEVEL verbose);
  1752. /**
  1753. * qdf_print_clean_node_flag() - Clean up node flag for print control object
  1754. *
  1755. * @idx: Index of print control object
  1756. *
  1757. * Return: None
  1758. */
  1759. void qdf_print_clean_node_flag(unsigned int idx);
  1760. #ifdef DBG_LVL_MAC_FILTERING
  1761. /**
  1762. * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
  1763. *
  1764. * @idx: Index of print control object
  1765. * @enable: Enable/Disable bit sent by callee
  1766. *
  1767. * Return: QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
  1768. */
  1769. QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
  1770. uint8_t enable);
  1771. /**
  1772. * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
  1773. *
  1774. * @idx: Index of print control object
  1775. *
  1776. * Return: Flag that indicates enable(1) or disable(0) or invalid(-1)
  1777. */
  1778. bool qdf_print_get_node_flag(unsigned int idx);
  1779. #endif
  1780. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  1781. /**
  1782. * qdf_module_param_handler() - Function to store module params
  1783. *
  1784. * @context: NULL, unused.
  1785. * @key: Name of the module param
  1786. * @value: Value of the module param
  1787. *
  1788. * Handler function to be called from qdf_ini_parse()
  1789. * function when a valid parameter is found in a file.
  1790. *
  1791. * Return: QDF_STATUS_SUCCESS on Success
  1792. */
  1793. QDF_STATUS qdf_module_param_handler(void *context, const char *key,
  1794. const char *value);
  1795. #else
  1796. static inline
  1797. QDF_STATUS qdf_module_param_handler(void *context, const char *key,
  1798. const char *value)
  1799. {
  1800. return QDF_STATUS_SUCCESS;
  1801. }
  1802. #endif
  1803. /**
  1804. * qdf_logging_init() - Initialize msg logging functionality
  1805. *
  1806. * Return: void
  1807. */
  1808. void qdf_logging_init(void);
  1809. /**
  1810. * qdf_logging_exit() - Cleanup msg logging functionality
  1811. *
  1812. * Return: void
  1813. */
  1814. void qdf_logging_exit(void);
  1815. #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
  1816. /**
  1817. * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
  1818. * @buffer: the string buffer to print into
  1819. * @addr: address of the symbol to lookup and print
  1820. *
  1821. * Return: number of characters printed
  1822. */
  1823. int qdf_sprint_symbol(char *buffer, void *addr);
  1824. /**
  1825. * qdf_minidump_init() - Initialize minidump functionality
  1826. *
  1827. *
  1828. * Return: void
  1829. */
  1830. static inline
  1831. void qdf_minidump_init(void)
  1832. {
  1833. __qdf_minidump_init();
  1834. }
  1835. /**
  1836. * qdf_minidump_deinit() - De-initialize minidump functionality
  1837. *
  1838. *
  1839. * Return: void
  1840. */
  1841. static inline
  1842. void qdf_minidump_deinit(void)
  1843. {
  1844. __qdf_minidump_deinit();
  1845. }
  1846. /**
  1847. * qdf_minidump_log() - Log memory address to be included in minidump
  1848. * @start_addr: Start address of the memory to be dumped
  1849. * @size: Size in bytes
  1850. * @name: String to identify this entry
  1851. */
  1852. static inline
  1853. void qdf_minidump_log(void *start_addr,
  1854. const size_t size, const char *name)
  1855. {
  1856. __qdf_minidump_log(start_addr, size, name);
  1857. }
  1858. /**
  1859. * qdf_minidump_remove() - Remove memory address from minidump
  1860. * @start_addr: Start address of the memory previously added
  1861. * @size: Size in bytes
  1862. * @name: String to identify this entry
  1863. */
  1864. static inline
  1865. void qdf_minidump_remove(void *start_addr,
  1866. const size_t size, const char *name)
  1867. {
  1868. __qdf_minidump_remove(start_addr, size, name);
  1869. }
  1870. #endif /* __QDF_TRACE_H */