xref: /wlan-dirver/qca-wifi-host-cmn/qdf/inc/qdf_trace.h (revision 9b24afb720cd7079342f34d267eef718e719ce65)
1 /*
2  * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 #if !defined(__QDF_TRACE_H)
29 #define __QDF_TRACE_H
30 
31 /**
32  *  DOC: qdf_trace
33  *  QCA driver framework trace APIs
34  *  Trace, logging, and debugging definitions and APIs
35  */
36 
37 /* Include Files */
38 #include  <qdf_types.h>         /* For QDF_MODULE_ID... */
39 #include  <stdarg.h>            /* For va_list... */
40 #include  <qdf_status.h>
41 #include  <qdf_nbuf.h>
42 #include  <i_qdf_types.h>
43 
44 /* Type declarations */
45 
46 #define FL(x)    "%s: %d: " x, __func__, __LINE__
47 #define QDF_TRACE_BUFFER_SIZE (512)
48 
49 #ifdef CONFIG_MCL
50 #define QDF_DEFAULT_TRACE_LEVEL \
51 	((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR))
52 #else
53 #define QDF_DEFAULT_TRACE_LEVEL (1 << QDF_TRACE_LEVEL_INFO)
54 #endif
55 
56 #define QDF_CATEGORY_INFO_U16(val) (((val >> 16) & 0x0000FFFF))
57 #define QDF_TRACE_LEVEL_INFO_L16(val) (val & 0x0000FFFF)
58 
59 typedef int (qdf_abstract_print)(void *priv, const char *fmt, ...);
60 
61 /*
62  * Log levels
63  */
64 #define QDF_DEBUG_FUNCTRACE     0x01
65 #define QDF_DEBUG_LEVEL0        0x02
66 #define QDF_DEBUG_LEVEL1        0x04
67 #define QDF_DEBUG_LEVEL2        0x08
68 #define QDF_DEBUG_LEVEL3        0x10
69 #define QDF_DEBUG_ERROR         0x20
70 #define QDF_DEBUG_CFG           0x40
71 
72 
73 /* DP Trace Implementation */
74 #ifdef CONFIG_DP_TRACE
75 #define DPTRACE(p) p
76 #else
77 #define DPTRACE(p)
78 #endif
79 
80 #ifdef CONFIG_MCL
81 void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data);
82 #endif
83 
84 /* By default Data Path module will have all log levels enabled, except debug
85  * log level. Debug level will be left up to the framework or user space modules
86  * to be enabled when issue is detected
87  */
88 #define QDF_DATA_PATH_TRACE_LEVEL \
89 	((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \
90 	(1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \
91 	(1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \
92 	(1 << QDF_TRACE_LEVEL_INFO_LOW))
93 
94 /* Preprocessor definitions and constants */
95 #define ASSERT_BUFFER_SIZE (512)
96 
97 #define QDF_TRACE_DEFAULT_PDEV_ID 0xff
98 #define MAX_QDF_TRACE_RECORDS 4000
99 #define INVALID_QDF_TRACE_ADDR 0xffffffff
100 #define DEFAULT_QDF_TRACE_DUMP_COUNT 0
101 
102 /*
103  * first parameter to iwpriv command - dump_dp_trace
104  * iwpriv wlan0 dump_dp_trace 0 0 -> dump full buffer
105  * iwpriv wlan0 dump_dp_trace 1 0 -> enable live view mode
106  * iwpriv wlan0 dump_dp_trace 2 0 -> clear dp trace buffer
107  * iwpriv wlan0 dump_dp_trace 3 0 -> disable live view mode
108  */
109 #define DUMP_DP_TRACE			0
110 #define ENABLE_DP_TRACE_LIVE_MODE	1
111 #define CLEAR_DP_TRACE_BUFFER		2
112 #define DISABLE_DP_TRACE_LIVE_MODE	3
113 
114 
115 #ifdef TRACE_RECORD
116 
117 #define MTRACE(p) p
118 #define NO_SESSION 0xFF
119 
120 #else
121 #define MTRACE(p) {  }
122 
123 #endif
124 
125 /**
126  * typedef struct qdf_trace_record_s - keep trace record
127  * @qtime: qtimer ticks
128  * @time: user timestamp
129  * @module: module name
130  * @code: hold record of code
131  * @session: hold record of session
132  * @data: hold data
133  * @pid: hold pid of the process
134  */
135 typedef struct qdf_trace_record_s {
136 	uint64_t qtime;
137 	char time[18];
138 	uint8_t module;
139 	uint8_t code;
140 	uint16_t session;
141 	uint32_t data;
142 	uint32_t pid;
143 } qdf_trace_record_t, *tp_qdf_trace_record;
144 
145 /**
146  * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer
147  * @head: position of first record
148  * @tail: position of last record
149  * @num: count of total record
150  * @num_since_last_dump: count from last dump
151  * @enable: config for controlling the trace
152  * @dump_count: Dump after number of records reach this number
153  */
154 typedef struct s_qdf_trace_data {
155 	uint32_t head;
156 	uint32_t tail;
157 	uint32_t num;
158 	uint16_t num_since_last_dump;
159 	uint8_t enable;
160 	uint16_t dump_count;
161 } t_qdf_trace_data;
162 
163 #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
164 
165 
166 #define MAX_QDF_DP_TRACE_RECORDS       4000
167 #define QDF_DP_TRACE_RECORD_SIZE       16
168 #define INVALID_QDF_DP_TRACE_ADDR      0xffffffff
169 #define QDF_DP_TRACE_VERBOSITY_HIGH    3
170 #define QDF_DP_TRACE_VERBOSITY_MEDIUM  2
171 #define QDF_DP_TRACE_VERBOSITY_LOW     1
172 #define QDF_DP_TRACE_VERBOSITY_BASE    0
173 
174 /**
175  * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
176  * @QDF_DP_TRACE_INVALID - invalid
177  * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet
178  * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet
179  * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet
180  * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet
181  * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt
182  * QDF_DP_TRACE_EVENT_RECORD - record events
183  * @QDF_DP_TRACE_BASE_VERBOSITY - below this are part of base verbosity
184  * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packets
185  * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD
186  * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD
187  * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout
188  * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout
189  * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record
190  * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity
191  * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record
192  * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record
193  * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record
194  * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record
195  * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record
196  * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record
197  * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record
198  * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record
199   * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity
200  * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record
201  * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
202  * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record
203  * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record
204  * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record
205  * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record
206  * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
207  * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record 32 bytes of tx pkt at LI_DP
208  * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record 32 bytes of rx pkt at LI_DP
209  * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD
210  *		- record 32 bytes of rx null_queue pkt at LI_DP
211  * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity
212  */
213 enum  QDF_DP_TRACE_ID {
214 	QDF_DP_TRACE_INVALID,
215 	QDF_DP_TRACE_DROP_PACKET_RECORD,
216 	QDF_DP_TRACE_EAPOL_PACKET_RECORD,
217 	QDF_DP_TRACE_DHCP_PACKET_RECORD,
218 	QDF_DP_TRACE_ARP_PACKET_RECORD,
219 	QDF_DP_TRACE_MGMT_PACKET_RECORD,
220 	QDF_DP_TRACE_EVENT_RECORD,
221 	QDF_DP_TRACE_BASE_VERBOSITY,
222 	QDF_DP_TRACE_ICMP_PACKET_RECORD,
223 	QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
224 	QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
225 	QDF_DP_TRACE_HDD_TX_TIMEOUT,
226 	QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
227 	QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
228 	QDF_DP_TRACE_LOW_VERBOSITY,
229 	QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
230 	QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
231 	QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
232 	QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
233 	QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
234 	QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
235 	QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
236 	QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD,
237 	QDF_DP_TRACE_MED_VERBOSITY,
238 	QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
239 	QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
240 	QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
241 	QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
242 	QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
243 	QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
244 	QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
245 	QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
246 	QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD,
247 	QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD,
248 	QDF_DP_TRACE_HIGH_VERBOSITY,
249 	QDF_DP_TRACE_MAX
250 };
251 
252 /**
253  * qdf_proto_dir - direction
254  * @QDF_TX: TX direction
255  * @QDF_RX: RX direction
256  * @QDF_NA: not applicable
257  */
258 enum qdf_proto_dir {
259 	QDF_TX,
260 	QDF_RX,
261 	QDF_NA
262 };
263 
264 /**
265  * struct qdf_dp_trace_ptr_buf - pointer record buffer
266  * @cookie: cookie value
267  * @msdu_id: msdu_id
268  * @status: completion status
269  */
270 struct qdf_dp_trace_ptr_buf {
271 	uint64_t cookie;
272 	uint16_t msdu_id;
273 	uint16_t status;
274 };
275 
276 /**
277  * struct qdf_dp_trace_proto_buf - proto packet buffer
278  * @sa: source address
279  * @da: destination address
280  * @vdev_id : vdev id
281  * @type: packet type
282  * @subtype: packet subtype
283  * @dir: direction
284  */
285 struct qdf_dp_trace_proto_buf {
286 	struct qdf_mac_addr sa;
287 	struct qdf_mac_addr da;
288 	uint8_t vdev_id;
289 	uint8_t type;
290 	uint8_t subtype;
291 	uint8_t dir;
292 };
293 
294 /**
295  * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
296  * @vdev_id : vdev id
297  * @type: packet type
298  * @subtype: packet subtype
299  */
300 struct qdf_dp_trace_mgmt_buf {
301 	uint8_t vdev_id;
302 	uint8_t type;
303 	uint8_t subtype;
304 };
305 
306 /**
307  * struct qdf_dp_trace_event_buf - event buffer
308  * @vdev_id : vdev id
309  * @type: packet type
310  * @subtype: packet subtype
311  */
312 struct qdf_dp_trace_event_buf {
313 	uint8_t vdev_id;
314 	uint8_t type;
315 	uint8_t subtype;
316 };
317 
318 /**
319  * struct qdf_dp_trace_record_s - Describes a record in DP trace
320  * @time: time when it got stored
321  * @code: Describes the particular event
322  * @data: buffer to store data
323  * @size: Length of the valid data stored in this record
324  * @pid : process id which stored the data in this record
325  */
326 struct qdf_dp_trace_record_s {
327 	char time[20];
328 	uint8_t code;
329 	uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
330 	uint8_t size;
331 	uint32_t pid;
332 	uint8_t pdev_id;
333 };
334 
335 /**
336  * struct qdf_dp_trace_data - Parameters to configure/control DP trace
337  * @head: Position of first record
338  * @tail: Position of last record
339  * @num:  Current index
340  * @proto_bitmap: defines which protocol to be traced
341  * @no_of_record: defines every nth packet to be traced
342  * @verbosity : defines verbosity level
343  * @enable: enable/disable DP trace
344  * @count: current packet number
345  * @live_mode_config: configuration as received during initialization
346  * @live_mode: current live mode, enabled or disabled.
347  * @print_pkt_cnt: count of number of packets printed in live mode
348  *.@high_tput_thresh: thresh beyond which live mode is turned off
349  *.@thresh_time_limit: max time, in terms of BW timer intervals to wait,
350  *	         for determining if high_tput_thresh has been crossed. ~1s
351  *.@arp_req: stats for arp reqs
352  *.@arp_resp: stats for arp resps
353  *.@icmp_req: stats for icmp reqs
354  *.@icmp_req: stats for icmp resps
355 
356  */
357 struct s_qdf_dp_trace_data {
358 	uint32_t head;
359 	uint32_t tail;
360 	uint32_t num;
361 	uint8_t proto_bitmap;
362 	uint8_t no_of_record;
363 	uint8_t verbosity;
364 	bool enable;
365 	bool live_mode_config;
366 	bool live_mode;
367 	uint8_t print_pkt_cnt;
368 	uint8_t high_tput_thresh;
369 	uint16_t thresh_time_limit;
370 	/* Stats */
371 	uint32_t tx_count;
372 	uint32_t rx_count;
373 	uint32_t arp_req;
374 	uint32_t arp_resp;
375 	uint32_t icmp_req;
376 	uint32_t icmp_resp;
377 };
378 
379 
380 /* Function declarations and documenation */
381 
382 /**
383  * qdf_trace_set_level() - Set the trace level for a particular module
384  * @level : trace level
385  *
386  * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating
387  * the severity of the condition causing the trace message to be issued.
388  * More severe conditions are more likely to be logged.
389  *
390  * This is an external API that allows trace levels to be set for each module.
391  *
392  * Return:  nothing
393  */
394 void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
395 
396 /**
397  * qdf_trace_get_level() - get the trace level
398  * @level : trace level
399  *
400  * This is an external API that returns a bool value to signify if a
401  * particular trace level is set for the specified module.
402  * A member of the QDF_TRACE_LEVEL enumeration indicating the severity
403  * of the condition causing the trace message to be issued.
404  *
405  * Note that individual trace levels are the only valid values
406  * for this API.  QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL
407  * are not valid input and will return false
408  *
409  * Return:
410  *  false - the specified trace level for the specified module is OFF
411  *  true - the specified trace level for the specified module is ON
412  */
413 bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
414 
415 typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
416 typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
417 void qdf_register_debugcb_init(void);
418 void qdf_register_debug_callback(QDF_MODULE_ID module_id,
419 					tp_qdf_state_info_cb qdf_state_infocb);
420 QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
421 			uint16_t *driver_dump_size);
422 void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb);
423 QDF_STATUS qdf_trace_spin_lock_init(void);
424 void qdf_trace_init(void);
425 void qdf_trace_enable(uint32_t, uint8_t enable);
426 void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
427 
428 
429 #ifdef CONFIG_DP_TRACE
430 void qdf_dp_set_proto_bitmap(uint32_t val);
431 void qdf_dp_trace_set_verbosity(uint32_t val);
432 void qdf_dp_set_no_of_record(uint32_t val);
433 bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
434 				enum qdf_proto_dir dir, uint8_t pdev_id);
435 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
436 				uint16_t time_limit, uint8_t verbosity,
437 				uint8_t proto_bitmap);
438 void qdf_dp_trace_spin_lock_init(void);
439 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
440 			 uint8_t verbosity);
441 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
442 void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
443 			uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
444 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
445 typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
446 					uint16_t, uint8_t, bool live);
447 void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
448 					uint16_t index, uint8_t pdev_id, bool live);
449 void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
450 	uint8_t pdev_id, uint8_t *data, uint8_t size, uint16_t msdu_id,
451 	uint16_t status);
452 void qdf_dp_trace_throttle_live_mode(bool high_bw_request);
453 void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *pRecord,
454 				uint16_t recIndex, uint8_t pdev_id, bool live);
455 void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
456 					 uint16_t index, uint8_t pdev_id, bool live);
457 uint8_t qdf_dp_get_proto_bitmap(void);
458 uint8_t qdf_dp_get_verbosity(void);
459 uint8_t qdf_dp_get_no_of_record(void);
460 void
461 qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
462 	uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
463 	enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
464 	uint8_t pdev_id, bool print);
465 void qdf_dp_trace_disable_live_mode(void);
466 void qdf_dp_trace_enable_live_mode(void);
467 void qdf_dp_trace_clear_buffer(void);
468 void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
469 	uint8_t pdev_id, enum qdf_proto_type type,
470 	enum qdf_proto_subtype subtype);
471 void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
472 			      uint16_t index, uint8_t pdev_id,  bool live);
473 void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
474 			      uint16_t index, uint8_t pdev_id, bool live);
475 void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
476 	uint8_t pdev_id, enum qdf_proto_type type,
477 	enum qdf_proto_subtype subtype);
478 #else
479 static inline
480 bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
481 				enum qdf_proto_dir dir, uint8_t pdev_id)
482 {
483 	return false;
484 }
485 static inline
486 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh,
487 				uint16_t time_limit, uint8_t verbosity,
488 				uint8_t proto_bitmap)
489 {
490 }
491 static inline
492 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
493 {
494 }
495 static inline
496 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
497 			 uint8_t verbosity)
498 {
499 }
500 static inline
501 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
502 {
503 }
504 
505 static inline
506 void qdf_dp_trace_disable_live_mode(void)
507 {
508 }
509 
510 static inline
511 void qdf_dp_trace_enable_live_mode(void)
512 {
513 }
514 
515 static inline
516 void qdf_dp_trace_throttle_live_mode(bool high_bw_request)
517 {
518 }
519 
520 static inline
521 void qdf_dp_trace_clear_buffer(void)
522 {
523 }
524 
525 #endif
526 
527 
528 
529 void qdf_trace_display(void);
530 
531 void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
532 			 uint8_t on);
533 
534 void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level);
535 
536 void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
537 		  char *str_format, ...);
538 
539 #define QDF_SNPRINTF qdf_snprintf
540 
541 #ifdef TSOSEG_DEBUG
542 static inline
543 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
544 			   uint16_t caller)
545 {
546 	int rc = -1;
547 
548 	if (tsoseg != NULL) {
549 		tsoseg->dbg.cur++;  tsoseg->dbg.cur &= 0x0f;
550 		tsoseg->dbg.history[tsoseg->dbg.cur] = caller;
551 		rc = tsoseg->dbg.cur;
552 	}
553 	return rc;
554 };
555 static inline void qdf_tso_seg_dbg_bug(char *msg)
556 {
557 	qdf_print(msg);
558 	QDF_BUG(0);
559 };
560 
561 static inline void
562 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
563 {
564 	tsoseg->dbg.txdesc = owner;
565 };
566 
567 static inline void
568 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
569 {
570 	memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
571 	return;
572 };
573 
574 #else
575 static inline
576 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
577 			   uint16_t caller)
578 {
579 	return 0;
580 };
581 static inline void qdf_tso_seg_dbg_bug(char *msg)
582 {
583 };
584 static inline void
585 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
586 {
587 };
588 static inline int
589 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
590 {
591 	memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
592 	return 0;
593 };
594 
595 #endif /* TSOSEG_DEBUG */
596 
597 void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
598 			void *data, int buf_len);
599 
600 #define ERROR_CODE                      -1
601 #define QDF_MAX_NAME_SIZE               32
602 #define MAX_PRINT_CONFIG_SUPPORTED      32
603 
604 #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
605 
606 /**
607  * qdf_set_pidx() - Sets the global qdf_pidx.
608  * @pidx : Index of print control object assigned to the module
609  *
610  */
611 void qdf_set_pidx(int pidx);
612 
613 /**
614  * qdf_get_pidx() - Returns the global qdf_pidx.
615  *
616  * Return : Current qdf print index.
617  */
618 int qdf_get_pidx(void);
619 /*
620  * Shared print control index
621  * for converged debug framework
622  */
623 
624 #define QDF_PRINT_IDX_SHARED -1
625 
626 /**
627  * QDF_PRINT_INFO() - Generic wrapper API for logging
628  * @idx : Index of print control object
629  * @module : Module identifier. A member of QDF_MODULE_ID enumeration that
630  *           identifies the module issuing the trace message
631  * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
632  *          the severity of the condition causing the trace message to be
633  *          issued.
634  * @str_format : Format string that contains the message to be logged.
635  *
636  *
637  * This wrapper will be used for any generic logging messages. Wrapper will
638  * compile a call to converged QDF trace message API.
639  *
640  * Return : Nothing
641  *
642  */
643 void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
644 		    QDF_TRACE_LEVEL level,
645 		    char *str_format, ...);
646 
647 /**
648  * struct category_info  : Category information structure
649  * @category_verbose_mask: Embeds information about category's verbose level
650  */
651 struct category_info {
652 	uint16_t category_verbose_mask;
653 };
654 
655 /**
656  * struct category_name_info  : Category name information structure
657  * @category_name_str: Embeds information about category name
658  */
659 struct category_name_info {
660 	unsigned char category_name_str[QDF_MAX_NAME_SIZE];
661 };
662 
663 /**
664  * qdf_trace_msg_cmn()- Converged logging API
665  * @idx: Index of print control object assigned to the module
666  * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
667  *            that identifies the category issuing the trace message.
668  * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
669  *           indicating the severity of the condition causing the trace
670  *           message to be issued. More severe conditions are more likely
671  *           to be logged.
672  * @str_format: Format string. The message to be logged. This format string
673  *              contains printf-like replacement parameters, which follow this
674  *              parameter in the variable argument list.
675  * @val: Variable argument list part of the log message
676  *
677  * Return: nothing
678  *
679  */
680 void qdf_trace_msg_cmn(unsigned int idx,
681 			QDF_MODULE_ID category,
682 			QDF_TRACE_LEVEL verbose,
683 			const char *str_format,
684 			va_list val);
685 
686 /**
687  * struct qdf_print_ctrl: QDF Print Control structure
688  *                        Statically allocated objects of print control
689  *                        structure are declared that will support maximum of
690  *                        32 print control objects. Any module that needs to
691  *                        register to the print control framework needs to
692  *                        obtain a print control object using
693  *                        qdf_print_ctrl_register API. It will have to pass
694  *                        pointer to category info structure, name and
695  *                        custom print function to be used if required.
696  * @name                : Optional name for the control object
697  * @cat_info            : Array of category_info struct
698  * @custom_print        : Custom print handler
699  * @custom_ctxt         : Custom print context
700  * @dbglvlmac_on        : Flag to enable/disable MAC level filtering
701  * @in_use              : Boolean to indicate if control object is in use
702  */
703 struct qdf_print_ctrl {
704 	char name[QDF_MAX_NAME_SIZE];
705 	struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
706 	void (*custom_print)(void *ctxt, const char *fmt, va_list args);
707 	void *custom_ctxt;
708 #ifdef DBG_LVL_MAC_FILTERING
709 	unsigned char dbglvlmac_on;
710 #endif
711 	bool in_use;
712 };
713 
714 /**
715  * qdf_print_ctrl_register() - Allocate QDF print control object, assign
716  *                             pointer to category info or print control
717  *                             structure and return the index to the callee
718  * @cinfo                 : Pointer to array of category info structure
719  * @custom_print_handler  : Pointer to custom print handler
720  * @custom_ctx            : Pointer to custom context
721  * @pctrl_name            : Pointer to print control object name
722  *
723  * Return                 : Index of qdf_print_ctrl structure
724  *
725  */
726 int qdf_print_ctrl_register(const struct category_info *cinfo,
727 			    void *custom_print_handler,
728 			    void *custom_ctx,
729 			    const char *pctrl_name);
730 
731 /**
732  * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
733  *                                all categories set to the default level
734  *
735  * Return                 : void
736  *
737  */
738 void qdf_shared_print_ctrl_init(void);
739 
740 /**
741  * qdf_print_setup() - Setup default values to all the print control objects
742  *
743  * Register new print control object for the callee
744  *
745  * Return :             QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
746  *                      on failure
747  */
748 QDF_STATUS qdf_print_setup(void);
749 
750 /**
751  * qdf_print_ctrl_cleanup() - Clean up a print control object
752  *
753  * Cleanup the print control object for the callee
754  *
755  * @pctrl : Index of print control object
756  *
757  * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
758  */
759 QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
760 
761 /**
762  * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object
763  *
764  * Cleanup the shared print-ctrl-object
765  *
766  * Return : void
767  */
768 void qdf_shared_print_ctrl_cleanup(void);
769 
770 /**
771  * qdf_print_set_category_verbose() - Enable/Disable category for a
772  *                                    print control object with
773  *                                    user provided verbose level
774  *
775  * @idx : Index of the print control object assigned to callee
776  * @category : Category information
777  * @verbose: Verbose information
778  * @is_set: Flag indicating if verbose level needs to be enabled or disabled
779  *
780  * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
781  */
782 QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
783 					  QDF_MODULE_ID category,
784 					  QDF_TRACE_LEVEL verbose,
785 					  bool is_set);
786 
787 /**
788  * qdf_print_is_category_enabled() - Get category information for the
789  *                                   print control object
790  *
791  * @idx : Index of print control object
792  * @category : Category information
793  *
794  * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
795  */
796 bool qdf_print_is_category_enabled(unsigned int idx,
797 				   QDF_MODULE_ID category);
798 
799 /**
800  * qdf_print_is_verbose_enabled() - Get verbose information of a category for
801  *                                  the print control object
802  *
803  * @idx : Index of print control object
804  * @category : Category information
805  * @verbose : Verbose information
806  *
807  * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
808  */
809 bool qdf_print_is_verbose_enabled(unsigned int idx,
810 				  QDF_MODULE_ID category,
811 				  QDF_TRACE_LEVEL verbose);
812 
813 /**
814  * qdf_print_clean_node_flag() - Clean up node flag for print control object
815  *
816  * @idx : Index of print control object
817  *
818  * Return : None
819  */
820 void qdf_print_clean_node_flag(unsigned int idx);
821 
822 #ifdef DBG_LVL_MAC_FILTERING
823 
824 /**
825  * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
826  *
827  * @idx : Index of print control object
828  * @enable : Enable/Disable bit sent by callee
829  *
830  * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
831  */
832 QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
833 				   uint8_t enable);
834 
835 /**
836  * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
837  *
838  * @idx : Index of print control object
839  *
840  * Return : Flag that indicates enable(1) or disable(0) or invalid(-1)
841  */
842 bool qdf_print_get_node_flag(unsigned int idx);
843 
844 #endif
845 
846 /**
847  * qdf_logging_init() - Initialize msg logging functionality
848  *
849  *
850  * Return : void
851  */
852 void qdf_logging_init(void);
853 
854 /**
855  * qdf_logging_exit() - Cleanup msg logging functionality
856  *
857  *
858  * Return : void
859  */
860 void qdf_logging_exit(void);
861 
862 #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
863 
864 /**
865  * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
866  * @buffer: the string buffer to print into
867  * @addr: address of the symbol to lookup and print
868  *
869  * Return: number of characters printed
870  */
871 int qdf_sprint_symbol(char *buffer, void *addr);
872 
873 #endif /* __QDF_TRACE_H */
874