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