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