qdf_trace.h 58 KB

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