qdf_trace.h 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037
  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 50 /* 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. *
  860. * Return: true: some protocol was logged, false: no protocol was logged.
  861. */
  862. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  863. enum qdf_proto_dir dir, uint8_t pdev_id);
  864. /**
  865. * qdf_dp_trace_init() - enables the DP trace
  866. * @live_mode_config: live mode configuration
  867. * @thresh: high throughput threshold for disabling live mode
  868. * @time_limit: max time to wait before deciding if thresh is crossed
  869. * @verbosity: dptrace verbosity level
  870. * @proto_bitmap: bitmap to enable/disable specific protocols
  871. *
  872. * Called during driver load to init dptrace
  873. *
  874. * A brief note on the 'thresh' param -
  875. * Total # of packets received in a bandwidth timer interval beyond which
  876. * DP Trace logging for data packets (including ICMP) will be disabled.
  877. * In memory logging will still continue for these packets. Other packets for
  878. * which proto.bitmap is set will continue to be recorded in logs and in memory.
  879. *
  880. * Return: None
  881. */
  882. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  883. uint16_t time_limit, uint8_t verbosity,
  884. uint32_t proto_bitmap);
  885. void qdf_dp_trace_deinit(void);
  886. /**
  887. * qdf_dp_trace_spin_lock_init() - initializes the lock variable before use
  888. * This function will be called from cds_alloc_global_context, we will have lock
  889. * available to use ASAP
  890. *
  891. * Return: None
  892. */
  893. void qdf_dp_trace_spin_lock_init(void);
  894. /**
  895. * qdf_dp_trace_set_value() - Configure the value to control DP trace
  896. * @proto_bitmap: defines the protocol to be tracked
  897. * @no_of_records: defines the nth packet which is traced
  898. * @verbosity: defines the verbosity level
  899. *
  900. * Return: None
  901. */
  902. void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records,
  903. uint8_t verbosity);
  904. /**
  905. * qdf_dp_trace_set_track() - Marks whether the packet needs to be traced
  906. * @nbuf: defines the netbuf
  907. * @dir: direction
  908. *
  909. * Return: None
  910. */
  911. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
  912. /**
  913. * qdf_dp_trace() - Stores the data in buffer
  914. * @nbuf: defines the netbuf
  915. * @code: defines the event
  916. * @pdev_id: pdev_id
  917. * @data: defines the data to be stored
  918. * @size: defines the size of the data record
  919. * @dir: direction
  920. *
  921. * Return: None
  922. */
  923. void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
  924. uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
  925. /**
  926. * qdf_dp_trace_dump_all() - Dump data from ring buffer via call back functions
  927. * registered with QDF
  928. * @count: Number of lines to dump starting from tail to head
  929. * @pdev_id: pdev_id
  930. *
  931. * Return: None
  932. */
  933. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
  934. /**
  935. * qdf_dpt_get_curr_pos_debugfs() - get curr position to start read
  936. * @file: debugfs file to read
  937. * @state: state to control read to debugfs file
  938. *
  939. * Return: curr pos
  940. */
  941. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  942. enum qdf_dpt_debugfs_state state);
  943. /**
  944. * qdf_dpt_dump_stats_debugfs() - dump DP Trace stats to debugfs file
  945. * @file: debugfs file to read
  946. * @curr_pos: curr position to start read
  947. *
  948. * Return: QDF_STATUS
  949. */
  950. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  951. uint32_t curr_pos);
  952. /**
  953. * qdf_dpt_set_value_debugfs() - set value of DP Trace debugfs params
  954. * @proto_bitmap: defines which protocol to be traced
  955. * @no_of_record: defines every nth packet to be traced
  956. * @verbosity: defines verbosity level
  957. * @num_records_to_dump: defines number of records to be dumped
  958. *
  959. * Return: none
  960. */
  961. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  962. uint8_t verbosity, uint16_t num_records_to_dump);
  963. /**
  964. * qdf_dp_trace_dump_stats() - dump DP Trace stats
  965. *
  966. * Return: none
  967. */
  968. void qdf_dp_trace_dump_stats(void);
  969. typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
  970. uint16_t, uint8_t, uint8_t info);
  971. /**
  972. * qdf_dp_display_record() - Displays a record in DP trace
  973. * @record: pointer to a record in DP trace
  974. * @index: record index
  975. * @pdev_id: pdev id for the mgmt pkt
  976. * @info: info used to display pkt (live mode, throttling)
  977. *
  978. * Return: None
  979. */
  980. void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
  981. uint16_t index, uint8_t pdev_id,
  982. uint8_t info);
  983. /**
  984. * qdf_dp_display_ptr_record() - display record
  985. * @record: dptrace record
  986. * @rec_index: index
  987. * @pdev_id: pdev id for the mgmt pkt
  988. * @info: info used to display pkt (live mode, throttling)
  989. *
  990. * Return: none
  991. */
  992. void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record,
  993. uint16_t rec_index, uint8_t pdev_id,
  994. uint8_t info);
  995. /**
  996. * qdf_dp_display_proto_pkt() - display proto packet
  997. * @record: dptrace record
  998. * @index: index
  999. * @pdev_id: pdev id for the mgmt pkt
  1000. * @info: info used to display pkt (live mode, throttling)
  1001. *
  1002. * Return: none
  1003. */
  1004. void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
  1005. uint16_t index, uint8_t pdev_id,
  1006. uint8_t info);
  1007. /**
  1008. * qdf_dp_display_data_pkt_record() - Displays a data packet in DP trace
  1009. * @record: pointer to a record in DP trace
  1010. * @rec_index: record index
  1011. * @pdev_id: pdev id
  1012. * @info: display info regarding record
  1013. *
  1014. * Return: None
  1015. */
  1016. void
  1017. qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record,
  1018. uint16_t rec_index, uint8_t pdev_id,
  1019. uint8_t info);
  1020. /**
  1021. * qdf_dp_get_status_from_htt() - Convert htt tx status to qdf dp status
  1022. * @status: htt_tx_status which needs to be converted
  1023. *
  1024. * Return: the status that from qdf_dp_tx_rx_status
  1025. */
  1026. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status);
  1027. /**
  1028. * qdf_dp_get_status_from_a_status() - Convert A_STATUS to qdf dp status
  1029. * @status: A_STATUS which needs to be converted
  1030. *
  1031. * Return: the status that from qdf_dp_tx_rx_status
  1032. */
  1033. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status);
  1034. /**
  1035. * qdf_dp_trace_ptr() - record dptrace
  1036. * @nbuf: network buffer
  1037. * @code: dptrace code
  1038. * @pdev_id: pdev_id
  1039. * @data: data
  1040. * @size: size of data
  1041. * @msdu_id: msdu_id
  1042. * @buf_arg_status: return status
  1043. * @qdf_tx_status: qdf tx rx status
  1044. *
  1045. * Return: none
  1046. */
  1047. void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
  1048. uint8_t pdev_id, uint8_t *data, uint8_t size,
  1049. uint16_t msdu_id, uint16_t buf_arg_status,
  1050. enum qdf_dp_tx_rx_status qdf_tx_status);
  1051. /**
  1052. * qdf_dp_trace_throttle_live_mode() - Throttle DP Trace live mode
  1053. * @high_bw_request: whether this is a high BW req or not
  1054. *
  1055. * The function tries to prevent excessive logging into the live buffer by
  1056. * having an upper limit on number of packets that can be logged per second.
  1057. *
  1058. * The intention is to allow occasional pings and data packets and really low
  1059. * throughput levels while suppressing bursts and higher throughput levels so
  1060. * that we donot hog the live buffer.
  1061. *
  1062. * If the number of packets printed in a particular second exceeds the thresh,
  1063. * disable printing in the next second.
  1064. *
  1065. * Return: None
  1066. */
  1067. void qdf_dp_trace_throttle_live_mode(bool high_bw_request);
  1068. /**
  1069. * qdf_dp_trace_apply_tput_policy() - Change verbosity based on the TPUT
  1070. * @is_data_traffic: Is traffic more than low TPUT threashould
  1071. *
  1072. * Return: None
  1073. */
  1074. void qdf_dp_trace_apply_tput_policy(bool is_data_traffic);
  1075. /**
  1076. * qdf_dp_trace_data_pkt() - trace data packet
  1077. * @nbuf: nbuf which needs to be traced
  1078. * @pdev_id: pdev_id
  1079. * @code: QDF_DP_TRACE_ID for the packet (TX or RX)
  1080. * @msdu_id: tx desc id for the nbuf (Only applies to TX packets)
  1081. * @dir: TX or RX packet direction
  1082. *
  1083. * Return: None
  1084. */
  1085. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  1086. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  1087. enum qdf_proto_dir dir);
  1088. /**
  1089. * qdf_dp_get_proto_bitmap() - get dp trace proto bitmap
  1090. *
  1091. * Return: proto bitmap
  1092. */
  1093. uint32_t qdf_dp_get_proto_bitmap(void);
  1094. uint8_t qdf_dp_get_verbosity(void);
  1095. /**
  1096. * qdf_dp_get_no_of_record() - get dp trace no_of_record
  1097. *
  1098. * Return: number of records
  1099. */
  1100. uint8_t qdf_dp_get_no_of_record(void);
  1101. /**
  1102. * qdf_dp_trace_proto_pkt() - record proto packet
  1103. * @code: dptrace code
  1104. * @vdev_id: vdev id
  1105. * @sa: source mac address
  1106. * @da: destination mac address
  1107. * @type: proto type
  1108. * @subtype: proto subtype
  1109. * @dir: direction
  1110. * @pdev_id: pdev id
  1111. * @print: to print this proto pkt or not
  1112. * @proto_priv_data: protocol specific private
  1113. * data.
  1114. * Return: none
  1115. */
  1116. void
  1117. qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1118. uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
  1119. enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
  1120. uint8_t pdev_id, bool print, uint32_t proto_priv_data);
  1121. /**
  1122. * qdf_dp_trace_disable_live_mode() - disable live mode for dptrace
  1123. *
  1124. * Return: none
  1125. */
  1126. void qdf_dp_trace_disable_live_mode(void);
  1127. /**
  1128. * qdf_dp_trace_enable_live_mode() - enable live mode for dptrace
  1129. *
  1130. * Return: none
  1131. */
  1132. void qdf_dp_trace_enable_live_mode(void);
  1133. /**
  1134. * qdf_dp_trace_clear_buffer() - clear dp trace buffer
  1135. *
  1136. * Return: none
  1137. */
  1138. void qdf_dp_trace_clear_buffer(void);
  1139. /**
  1140. * qdf_dp_trace_mgmt_pkt() - record mgmt packet
  1141. * @code: dptrace code
  1142. * @vdev_id: vdev id
  1143. * @pdev_id: pdev_id
  1144. * @type: proto type
  1145. * @subtype: proto subtype
  1146. *
  1147. * Return: none
  1148. */
  1149. void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1150. uint8_t pdev_id, enum qdf_proto_type type,
  1151. enum qdf_proto_subtype subtype);
  1152. /**
  1153. * qdf_dp_trace_credit_record() - record credit update
  1154. * @source: source of record
  1155. * @operation: credit operation
  1156. * @delta: credit delta
  1157. * @total_credits: total credit
  1158. * @g0_credit: group 0 credit
  1159. * @g1_credit: group 1 credit
  1160. */
  1161. void qdf_dp_trace_credit_record(enum QDF_CREDIT_UPDATE_SOURCE source,
  1162. enum QDF_CREDIT_OPERATION operation,
  1163. int delta, int total_credits,
  1164. int g0_credit, int g1_credit);
  1165. /**
  1166. * qdf_dp_display_mgmt_pkt() - display proto packet
  1167. * @record: dptrace record
  1168. * @index: index
  1169. * @pdev_id: pdev id for the mgmt pkt
  1170. * @info: info used to display pkt (live mode, throttling)
  1171. *
  1172. * Return: none
  1173. */
  1174. void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
  1175. uint16_t index, uint8_t pdev_id, uint8_t info);
  1176. /**
  1177. * qdf_dp_display_credit_record() - display credit record
  1178. * @record: dptrace record
  1179. * @index: index
  1180. * @pdev_id: pdev id
  1181. * @info: metadeta info
  1182. */
  1183. void qdf_dp_display_credit_record(struct qdf_dp_trace_record_s *record,
  1184. uint16_t index, uint8_t pdev_id,
  1185. uint8_t info);
  1186. /**
  1187. * qdf_dp_display_event_record() - display event records
  1188. * @record: dptrace record
  1189. * @index: index
  1190. * @pdev_id: pdev id for the mgmt pkt
  1191. * @info: info used to display pkt (live mode, throttling)
  1192. *
  1193. * Return: none
  1194. */
  1195. void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
  1196. uint16_t index, uint8_t pdev_id, uint8_t info);
  1197. /**
  1198. * qdf_dp_trace_record_event() - record events
  1199. * @code: dptrace code
  1200. * @vdev_id: vdev id
  1201. * @pdev_id: pdev_id
  1202. * @type: proto type
  1203. * @subtype: proto subtype
  1204. *
  1205. * Return: none
  1206. */
  1207. void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
  1208. uint8_t pdev_id, enum qdf_proto_type type,
  1209. enum qdf_proto_subtype subtype);
  1210. /**
  1211. * qdf_dp_set_proto_event_bitmap() - Set the protocol event bitmap
  1212. * @value: proto event bitmap value.
  1213. *
  1214. * QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01
  1215. * QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  1216. * QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  1217. * QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  1218. *
  1219. * Return: none
  1220. */
  1221. void qdf_dp_set_proto_event_bitmap(uint32_t value);
  1222. /**
  1223. * qdf_dp_log_proto_pkt_info() - Send diag log event
  1224. * @sa: source MAC address
  1225. * @da: destination MAC address
  1226. * @type: pkt type
  1227. * @subtype: pkt subtype
  1228. * @dir: tx or rx
  1229. * @msdu_id: msdu id
  1230. * @status: status
  1231. *
  1232. * Return: none
  1233. */
  1234. void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type,
  1235. uint8_t subtype, uint8_t dir, uint16_t msdu_id,
  1236. uint8_t status);
  1237. /**
  1238. * qdf_dp_track_noack_check() - Check if no ack count should be tracked for
  1239. * the configured protocol packet types
  1240. * @nbuf: nbuf
  1241. * @subtype: subtype of packet to be tracked
  1242. *
  1243. * Return: none
  1244. */
  1245. void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype);
  1246. #else
  1247. static inline
  1248. bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb,
  1249. enum qdf_proto_dir dir, uint8_t pdev_id)
  1250. {
  1251. return false;
  1252. }
  1253. static inline
  1254. void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
  1255. uint16_t time_limit, uint8_t verbosity,
  1256. uint32_t proto_bitmap)
  1257. {
  1258. }
  1259. static inline
  1260. void qdf_dp_trace_deinit(void)
  1261. {
  1262. }
  1263. static inline
  1264. void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
  1265. {
  1266. }
  1267. static inline
  1268. void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records,
  1269. uint8_t verbosity)
  1270. {
  1271. }
  1272. static inline
  1273. void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
  1274. {
  1275. }
  1276. static inline
  1277. uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file,
  1278. enum qdf_dpt_debugfs_state state)
  1279. {
  1280. return 0;
  1281. }
  1282. static inline
  1283. QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file,
  1284. uint32_t curr_pos)
  1285. {
  1286. return QDF_STATUS_SUCCESS;
  1287. }
  1288. static inline
  1289. void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record,
  1290. uint8_t verbosity, uint16_t num_records_to_dump)
  1291. {
  1292. }
  1293. static inline void qdf_dp_trace_dump_stats(void)
  1294. {
  1295. }
  1296. static inline
  1297. void qdf_dp_trace_disable_live_mode(void)
  1298. {
  1299. }
  1300. static inline
  1301. void qdf_dp_trace_enable_live_mode(void)
  1302. {
  1303. }
  1304. static inline
  1305. void qdf_dp_trace_throttle_live_mode(bool high_bw_request)
  1306. {
  1307. }
  1308. static inline
  1309. void qdf_dp_trace_clear_buffer(void)
  1310. {
  1311. }
  1312. static inline
  1313. void qdf_dp_trace_apply_tput_policy(bool is_data_traffic)
  1314. {
  1315. }
  1316. static inline
  1317. void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id,
  1318. enum QDF_DP_TRACE_ID code, uint16_t msdu_id,
  1319. enum qdf_proto_dir dir)
  1320. {
  1321. }
  1322. static inline
  1323. void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type,
  1324. uint8_t subtype, uint8_t dir, uint16_t msdu_id,
  1325. uint8_t status)
  1326. {
  1327. }
  1328. static inline
  1329. void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype)
  1330. {
  1331. }
  1332. static inline
  1333. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status)
  1334. {
  1335. return QDF_TX_RX_STATUS_OK;
  1336. }
  1337. static inline
  1338. enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status)
  1339. {
  1340. return QDF_TX_RX_STATUS_OK;
  1341. }
  1342. #endif
  1343. /**
  1344. * qdf_trace_display() - Display trace
  1345. *
  1346. * Return: None
  1347. */
  1348. void qdf_trace_display(void);
  1349. /**
  1350. * qdf_snprintf() - wrapper function to snprintf
  1351. * @str_buffer: string Buffer
  1352. * @size: defines the size of the data record
  1353. * @str_format: Format string in which the message to be logged. This format
  1354. * string contains printf-like replacement parameters, which follow
  1355. * this parameter in the variable argument list.
  1356. *
  1357. * Return: num of bytes written to buffer
  1358. */
  1359. int __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
  1360. char *str_format, ...);
  1361. #define QDF_SNPRINTF qdf_snprintf
  1362. #ifdef TSOSEG_DEBUG
  1363. static inline void qdf_tso_seg_dbg_bug(char *msg)
  1364. {
  1365. qdf_print("%s", msg);
  1366. QDF_BUG(0);
  1367. };
  1368. /**
  1369. * qdf_tso_seg_dbg_init - initialize TSO segment debug structure
  1370. * @tsoseg: structure to initialize
  1371. *
  1372. * TSO segment dbg structures are attached to qdf_tso_seg_elem_t
  1373. * structures and are allocated only of TSOSEG_DEBUG is defined.
  1374. * When allocated, at the time of the tso_seg_pool initialization,
  1375. * which goes with tx_desc initialization (1:1), each structure holds
  1376. * a number of (currently 16) history entries, basically describing
  1377. * what operation has been performed on this particular tso_seg_elem.
  1378. * This history buffer is a circular buffer and the current index is
  1379. * held in an atomic variable called cur. It is incremented every
  1380. * operation. Each of these operations are added with the function
  1381. * qdf_tso_seg_dbg_record.
  1382. * For each segment, this initialization function MUST be called PRIOR
  1383. * TO any _dbg_record() function calls.
  1384. * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero)
  1385. * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element.
  1386. *
  1387. * Return:
  1388. * None
  1389. */
  1390. static inline
  1391. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  1392. {
  1393. tsoseg->dbg.txdesc = NULL;
  1394. qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */
  1395. }
  1396. /**
  1397. * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure
  1398. * @tsoseg: structure to initialize
  1399. * @id: operation ID (identifies the caller)
  1400. *
  1401. * Adds a history entry to the history circular buffer. Each entry
  1402. * contains an operation id (caller, as currently each ID is used only
  1403. * once in the source, so it directly identifies the src line that invoked
  1404. * the recording.
  1405. *
  1406. * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized
  1407. * by qdf_tso_seg_dbg_init.
  1408. *
  1409. * The entry to be added is written at the location pointed by the atomic
  1410. * variable called cur. Cur is an ever increasing atomic variable. It is
  1411. * masked so that only the lower 4 bits are used (16 history entries).
  1412. *
  1413. * Return:
  1414. * int: the entry this record was recorded at
  1415. */
  1416. static inline
  1417. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  1418. {
  1419. int rc = -1;
  1420. unsigned int c;
  1421. qdf_assert(tsoseg);
  1422. if (id == TSOSEG_LOC_ALLOC) {
  1423. c = qdf_atomic_read(&tsoseg->dbg.cur);
  1424. /* dont crash on the very first alloc on the segment */
  1425. c &= 0x0f;
  1426. /* allow only INIT and FREE ops before ALLOC */
  1427. if (tsoseg->dbg.h[c].id >= id)
  1428. qdf_tso_seg_dbg_bug("Rogue TSO seg alloc");
  1429. }
  1430. c = qdf_atomic_inc_return(&tsoseg->dbg.cur);
  1431. c &= 0x0f;
  1432. tsoseg->dbg.h[c].ts = qdf_get_log_timestamp();
  1433. tsoseg->dbg.h[c].id = id;
  1434. rc = c;
  1435. return rc;
  1436. };
  1437. static inline void
  1438. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  1439. {
  1440. if (tsoseg)
  1441. tsoseg->dbg.txdesc = owner;
  1442. };
  1443. static inline void
  1444. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  1445. {
  1446. memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
  1447. return;
  1448. };
  1449. #else
  1450. static inline
  1451. void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg)
  1452. {
  1453. };
  1454. static inline
  1455. int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id)
  1456. {
  1457. return 0;
  1458. };
  1459. static inline void qdf_tso_seg_dbg_bug(char *msg)
  1460. {
  1461. };
  1462. static inline void
  1463. qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
  1464. {
  1465. };
  1466. static inline int
  1467. qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
  1468. {
  1469. memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
  1470. return 0;
  1471. };
  1472. #endif /* TSOSEG_DEBUG */
  1473. /**
  1474. * qdf_trace_hex_dump() - externally called hex dump function
  1475. * @module: Module identifier a member of the QDF_MODULE_ID enumeration that
  1476. * identifies the module issuing the trace message.
  1477. * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating
  1478. * the severity of the condition causing the trace message to be
  1479. * issued. More severe conditions are more likely to be logged.
  1480. * @data: The base address of the buffer to be logged.
  1481. * @buf_len: The size of the buffer to be logged.
  1482. *
  1483. * Checks the level of severity and accordingly prints the trace messages
  1484. *
  1485. * Return: None
  1486. */
  1487. void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  1488. void *data, int buf_len);
  1489. /**
  1490. * qdf_trace_hex_ascii_dump() - externally called hex and ascii dump function
  1491. * @module: Module identifier a member of the QDF_MODULE_ID enumeration that
  1492. * identifies the module issuing the trace message.
  1493. * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating
  1494. * the severity of the condition causing the trace message to be
  1495. * issued. More severe conditions are more likely to be logged.
  1496. * @data: The base address of the buffer to be logged.
  1497. * @buf_len: The size of the buffer to be logged.
  1498. *
  1499. * Checks the level of severity and accordingly prints the trace messages
  1500. *
  1501. * Return: None
  1502. */
  1503. void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
  1504. void *data, int buf_len);
  1505. #define ERROR_CODE -1
  1506. #define QDF_MAX_NAME_SIZE 32
  1507. #define MAX_PRINT_CONFIG_SUPPORTED 32
  1508. #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
  1509. /**
  1510. * qdf_set_pidx() - Sets the global qdf_pidx.
  1511. * @pidx: Index of print control object assigned to the module
  1512. *
  1513. */
  1514. void qdf_set_pidx(int pidx);
  1515. /**
  1516. * qdf_get_pidx() - Returns the global qdf_pidx.
  1517. *
  1518. * Return: Current qdf print index.
  1519. */
  1520. int qdf_get_pidx(void);
  1521. /*
  1522. * Shared print control index
  1523. * for converged debug framework
  1524. */
  1525. #define QDF_PRINT_IDX_SHARED -1
  1526. /**
  1527. * QDF_PRINT_INFO() - Generic wrapper API for logging
  1528. * @idx: Index of print control object
  1529. * @module: Module identifier. A member of QDF_MODULE_ID enumeration that
  1530. * identifies the module issuing the trace message
  1531. * @level: Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
  1532. * the severity of the condition causing the trace message to be
  1533. * issued.
  1534. * @str_format: Format string that contains the message to be logged.
  1535. *
  1536. *
  1537. * This wrapper will be used for any generic logging messages. Wrapper will
  1538. * compile a call to converged QDF trace message API.
  1539. *
  1540. * Return: Nothing
  1541. *
  1542. */
  1543. void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
  1544. QDF_TRACE_LEVEL level,
  1545. char *str_format, ...);
  1546. /**
  1547. * struct category_info - Category information structure
  1548. * @category_verbose_mask: Embeds information about category's verbose level
  1549. */
  1550. struct category_info {
  1551. uint16_t category_verbose_mask;
  1552. };
  1553. /**
  1554. * struct category_name_info - Category name information structure
  1555. * @category_name_str: Embeds information about category name
  1556. */
  1557. struct category_name_info {
  1558. unsigned char category_name_str[QDF_MAX_NAME_SIZE];
  1559. };
  1560. /**
  1561. * qdf_trace_msg_cmn() - Converged logging API
  1562. * @idx: Index of print control object assigned to the module
  1563. * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
  1564. * that identifies the category issuing the trace message.
  1565. * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
  1566. * indicating the severity of the condition causing the trace
  1567. * message to be issued. More severe conditions are more likely
  1568. * to be logged.
  1569. * @str_format: Format string. The message to be logged. This format string
  1570. * contains printf-like replacement parameters, which follow this
  1571. * parameter in the variable argument list.
  1572. * @val: Variable argument list part of the log message
  1573. *
  1574. * Return: nothing
  1575. *
  1576. */
  1577. void qdf_trace_msg_cmn(unsigned int idx,
  1578. QDF_MODULE_ID category,
  1579. QDF_TRACE_LEVEL verbose,
  1580. const char *str_format,
  1581. va_list val);
  1582. /**
  1583. * struct qdf_print_ctrl - QDF Print Control structure
  1584. * Statically allocated objects of print control
  1585. * structure are declared that will support maximum of
  1586. * 32 print control objects. Any module that needs to
  1587. * register to the print control framework needs to
  1588. * obtain a print control object using
  1589. * qdf_print_ctrl_register API. It will have to pass
  1590. * pointer to category info structure, name and
  1591. * custom print function to be used if required.
  1592. * @name: Optional name for the control object
  1593. * @cat_info: Array of category_info struct
  1594. * @custom_print: Custom print handler
  1595. * @custom_ctxt: Custom print context
  1596. * @dbglvlmac_on: Flag to enable/disable MAC level filtering
  1597. * @in_use: Boolean to indicate if control object is in use
  1598. */
  1599. struct qdf_print_ctrl {
  1600. char name[QDF_MAX_NAME_SIZE];
  1601. struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
  1602. void (*custom_print)(void *ctxt, const char *fmt, va_list args);
  1603. void *custom_ctxt;
  1604. #ifdef DBG_LVL_MAC_FILTERING
  1605. unsigned char dbglvlmac_on;
  1606. #endif
  1607. bool in_use;
  1608. };
  1609. /**
  1610. * qdf_print_ctrl_register() - Allocate QDF print control object, assign
  1611. * pointer to category info or print control
  1612. * structure and return the index to the callee
  1613. * @cinfo: Pointer to array of category info structure
  1614. * @custom_print_handler: Pointer to custom print handler
  1615. * @custom_ctx: Pointer to custom context
  1616. * @pctrl_name: Pointer to print control object name
  1617. *
  1618. * Return: Index of qdf_print_ctrl structure
  1619. *
  1620. */
  1621. int qdf_print_ctrl_register(const struct category_info *cinfo,
  1622. void *custom_print_handler,
  1623. void *custom_ctx,
  1624. const char *pctrl_name);
  1625. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  1626. /**
  1627. * qdf_initialize_module_param_from_ini() - Update qdf module params
  1628. *
  1629. * Read the file which has wifi module params, parse and update
  1630. * qdf module params.
  1631. *
  1632. * Return: void
  1633. */
  1634. void qdf_initialize_module_param_from_ini(void);
  1635. #else
  1636. static inline
  1637. void qdf_initialize_module_param_from_ini(void)
  1638. {
  1639. }
  1640. #endif
  1641. /**
  1642. * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
  1643. * all categories set to the default level
  1644. *
  1645. * Return: void
  1646. *
  1647. */
  1648. void qdf_shared_print_ctrl_init(void);
  1649. /**
  1650. * qdf_print_setup() - Setup default values to all the print control objects
  1651. *
  1652. * Register new print control object for the callee
  1653. *
  1654. * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
  1655. * on failure
  1656. */
  1657. QDF_STATUS qdf_print_setup(void);
  1658. /**
  1659. * qdf_print_ctrl_cleanup() - Clean up a print control object
  1660. * @idx: Index of print control object
  1661. *
  1662. * Cleanup the print control object for the callee
  1663. *
  1664. * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
  1665. */
  1666. QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
  1667. /**
  1668. * qdf_shared_print_ctrl_cleanup() - Clean up of the shared object
  1669. *
  1670. * Cleanup the shared print-ctrl-object
  1671. *
  1672. * Return: void
  1673. */
  1674. void qdf_shared_print_ctrl_cleanup(void);
  1675. /**
  1676. * qdf_print_set_category_verbose() - Enable/Disable category for a
  1677. * print control object with
  1678. * user provided verbose level
  1679. * @idx: Index of the print control object assigned to callee
  1680. * @category: Category information
  1681. * @verbose: Verbose information
  1682. * @is_set: Flag indicating if verbose level needs to be enabled or disabled
  1683. *
  1684. * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1685. */
  1686. QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
  1687. QDF_MODULE_ID category,
  1688. QDF_TRACE_LEVEL verbose,
  1689. bool is_set);
  1690. /**
  1691. * qdf_log_dump_at_kernel_level() - Enable/Disable printk call
  1692. * @enable: Indicates whether printk is enabled in QDF_TRACE
  1693. *
  1694. * Return: void
  1695. */
  1696. void qdf_log_dump_at_kernel_level(bool enable);
  1697. /**
  1698. * qdf_logging_set_flush_timer() - Set the time period in which host logs
  1699. * should be flushed out to user-space
  1700. * @milliseconds: milliseconds after which the logs should be flushed out to
  1701. * user-space
  1702. *
  1703. * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
  1704. */
  1705. int qdf_logging_set_flush_timer(uint32_t milliseconds);
  1706. /**
  1707. * qdf_logging_flush_logs() - Flush out the logs to user-space one time
  1708. *
  1709. * Return: void
  1710. */
  1711. void qdf_logging_flush_logs(void);
  1712. /**
  1713. * qdf_print_is_category_enabled() - Get category information for the
  1714. * print control object
  1715. *
  1716. * @idx: Index of print control object
  1717. * @category: Category information
  1718. *
  1719. * Return: Verbose enabled(true) or disabled(false) or invalid input (false)
  1720. */
  1721. bool qdf_print_is_category_enabled(unsigned int idx,
  1722. QDF_MODULE_ID category);
  1723. /**
  1724. * qdf_print_is_verbose_enabled() - Get verbose information of a category for
  1725. * the print control object
  1726. *
  1727. * @idx: Index of print control object
  1728. * @category: Category information
  1729. * @verbose: Verbose information
  1730. *
  1731. * Return: Verbose enabled(true) or disabled(false) or invalid input (false)
  1732. */
  1733. bool qdf_print_is_verbose_enabled(unsigned int idx,
  1734. QDF_MODULE_ID category,
  1735. QDF_TRACE_LEVEL verbose);
  1736. /**
  1737. * qdf_print_clean_node_flag() - Clean up node flag for print control object
  1738. *
  1739. * @idx: Index of print control object
  1740. *
  1741. * Return: None
  1742. */
  1743. void qdf_print_clean_node_flag(unsigned int idx);
  1744. #ifdef DBG_LVL_MAC_FILTERING
  1745. /**
  1746. * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
  1747. *
  1748. * @idx: Index of print control object
  1749. * @enable: Enable/Disable bit sent by callee
  1750. *
  1751. * Return: QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
  1752. */
  1753. QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
  1754. uint8_t enable);
  1755. /**
  1756. * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
  1757. *
  1758. * @idx: Index of print control object
  1759. *
  1760. * Return: Flag that indicates enable(1) or disable(0) or invalid(-1)
  1761. */
  1762. bool qdf_print_get_node_flag(unsigned int idx);
  1763. #endif
  1764. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  1765. /**
  1766. * qdf_module_param_handler() - Function to store module params
  1767. *
  1768. * @context: NULL, unused.
  1769. * @key: Name of the module param
  1770. * @value: Value of the module param
  1771. *
  1772. * Handler function to be called from qdf_ini_parse()
  1773. * function when a valid parameter is found in a file.
  1774. *
  1775. * Return: QDF_STATUS_SUCCESS on Success
  1776. */
  1777. QDF_STATUS qdf_module_param_handler(void *context, const char *key,
  1778. const char *value);
  1779. #else
  1780. static inline
  1781. QDF_STATUS qdf_module_param_handler(void *context, const char *key,
  1782. const char *value)
  1783. {
  1784. return QDF_STATUS_SUCCESS;
  1785. }
  1786. #endif
  1787. /**
  1788. * qdf_logging_init() - Initialize msg logging functionality
  1789. *
  1790. * Return: void
  1791. */
  1792. void qdf_logging_init(void);
  1793. /**
  1794. * qdf_logging_exit() - Cleanup msg logging functionality
  1795. *
  1796. * Return: void
  1797. */
  1798. void qdf_logging_exit(void);
  1799. #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
  1800. /**
  1801. * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
  1802. * @buffer: the string buffer to print into
  1803. * @addr: address of the symbol to lookup and print
  1804. *
  1805. * Return: number of characters printed
  1806. */
  1807. int qdf_sprint_symbol(char *buffer, void *addr);
  1808. /**
  1809. * qdf_minidump_init() - Initialize minidump functionality
  1810. *
  1811. *
  1812. * Return: void
  1813. */
  1814. static inline
  1815. void qdf_minidump_init(void)
  1816. {
  1817. __qdf_minidump_init();
  1818. }
  1819. /**
  1820. * qdf_minidump_deinit() - De-initialize minidump functionality
  1821. *
  1822. *
  1823. * Return: void
  1824. */
  1825. static inline
  1826. void qdf_minidump_deinit(void)
  1827. {
  1828. __qdf_minidump_deinit();
  1829. }
  1830. /**
  1831. * qdf_minidump_log() - Log memory address to be included in minidump
  1832. * @start_addr: Start address of the memory to be dumped
  1833. * @size: Size in bytes
  1834. * @name: String to identify this entry
  1835. */
  1836. static inline
  1837. void qdf_minidump_log(void *start_addr,
  1838. const size_t size, const char *name)
  1839. {
  1840. __qdf_minidump_log(start_addr, size, name);
  1841. }
  1842. /**
  1843. * qdf_minidump_remove() - Remove memory address from minidump
  1844. * @start_addr: Start address of the memory previously added
  1845. * @size: Size in bytes
  1846. * @name: String to identify this entry
  1847. */
  1848. static inline
  1849. void qdf_minidump_remove(void *start_addr,
  1850. const size_t size, const char *name)
  1851. {
  1852. __qdf_minidump_remove(start_addr, size, name);
  1853. }
  1854. #endif /* __QDF_TRACE_H */