xref: /wlan-dirver/qca-wifi-host-cmn/qdf/inc/qdf_trace.h (revision a4b8d357569709a7889c418ba927c180e2cd45dc)
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 #define DUMP_DP_TRACE       0
103 #define ENABLE_DP_TRACE_LIVE_MODE	1
104 #define CLEAR_DP_TRACE_BUFFER	2
105 
106 #ifdef TRACE_RECORD
107 
108 #define MTRACE(p) p
109 #define NO_SESSION 0xFF
110 
111 #else
112 #define MTRACE(p) {  }
113 
114 #endif
115 
116 /**
117  * typedef struct qdf_trace_record_s - keep trace record
118  * @qtime: qtimer ticks
119  * @time: user timestamp
120  * @module: module name
121  * @code: hold record of code
122  * @session: hold record of session
123  * @data: hold data
124  * @pid: hold pid of the process
125  */
126 typedef struct qdf_trace_record_s {
127 	uint64_t qtime;
128 	char time[18];
129 	uint8_t module;
130 	uint8_t code;
131 	uint16_t session;
132 	uint32_t data;
133 	uint32_t pid;
134 } qdf_trace_record_t, *tp_qdf_trace_record;
135 
136 /**
137  * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer
138  * @head: position of first record
139  * @tail: position of last record
140  * @num: count of total record
141  * @num_since_last_dump: count from last dump
142  * @enable: config for controlling the trace
143  * @dump_count: Dump after number of records reach this number
144  */
145 typedef struct s_qdf_trace_data {
146 	uint32_t head;
147 	uint32_t tail;
148 	uint32_t num;
149 	uint16_t num_since_last_dump;
150 	uint8_t enable;
151 	uint16_t dump_count;
152 } t_qdf_trace_data;
153 
154 #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str);
155 
156 
157 #define MAX_QDF_DP_TRACE_RECORDS       4000
158 #define QDF_DP_TRACE_RECORD_SIZE       16
159 #define INVALID_QDF_DP_TRACE_ADDR      0xffffffff
160 #define QDF_DP_TRACE_VERBOSITY_HIGH    3
161 #define QDF_DP_TRACE_VERBOSITY_MEDIUM  2
162 #define QDF_DP_TRACE_VERBOSITY_LOW     1
163 #define QDF_DP_TRACE_VERBOSITY_DEFAULT 0
164 
165 /**
166  * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path
167  * @QDF_DP_TRACE_INVALID - invalid
168  * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet
169  * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet
170  * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet
171  * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet
172  * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt
173  * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packet
174  * QDF_DP_TRACE_EVENT_RECORD - record events
175  * @QDF_DP_TRACE_DEFAULT_VERBOSITY - below this are part of default verbosity
176  * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout
177  * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout
178  * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record
179  * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record
180  * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record
181  * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record
182  * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record
183  * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record
184  * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record
185  * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record
186  * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record
187  * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity
188  * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record
189  * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
190  * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record
191  * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record
192  * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record
193  * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record
194  * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record
195  * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity
196  * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD
197  * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD
198  * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record 32 bytes of tx pkt at LI_DP
199  * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record 32 bytes of rx pkt at LI_DP
200  * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD
201  *		- record 32 bytes of rx null_queue pkt at LI_DP
202  * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity
203  */
204 enum  QDF_DP_TRACE_ID {
205 	QDF_DP_TRACE_INVALID,
206 	QDF_DP_TRACE_DROP_PACKET_RECORD,
207 	QDF_DP_TRACE_EAPOL_PACKET_RECORD,
208 	QDF_DP_TRACE_DHCP_PACKET_RECORD,
209 	QDF_DP_TRACE_ARP_PACKET_RECORD,
210 	QDF_DP_TRACE_MGMT_PACKET_RECORD,
211 	QDF_DP_TRACE_ICMP_PACKET_RECORD,
212 	QDF_DP_TRACE_EVENT_RECORD,
213 	QDF_DP_TRACE_DEFAULT_VERBOSITY,
214 	QDF_DP_TRACE_HDD_TX_TIMEOUT,
215 	QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
216 	QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
217 	QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
218 	QDF_DP_TRACE_CE_PACKET_PTR_RECORD,
219 	QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD,
220 	QDF_DP_TRACE_FREE_PACKET_PTR_RECORD,
221 	QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD,
222 	QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD,
223 	QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
224 	QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD,
225 	QDF_DP_TRACE_LOW_VERBOSITY,
226 	QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
227 	QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD,
228 	QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD,
229 	QDF_DP_TRACE_HTT_PACKET_PTR_RECORD,
230 	QDF_DP_TRACE_HTC_PACKET_PTR_RECORD,
231 	QDF_DP_TRACE_HIF_PACKET_PTR_RECORD,
232 	QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD,
233 	QDF_DP_TRACE_MED_VERBOSITY,
234 	QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
235 	QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
236 	QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
237 	QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD,
238 	QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD,
239 	QDF_DP_TRACE_HIGH_VERBOSITY,
240 	QDF_DP_TRACE_MAX
241 };
242 
243 /**
244  * qdf_proto_dir - direction
245  * @QDF_TX: TX direction
246  * @QDF_RX: RX direction
247  * @QDF_NA: not applicable
248  */
249 enum qdf_proto_dir {
250 	QDF_TX,
251 	QDF_RX,
252 	QDF_NA
253 };
254 
255 /**
256  * struct qdf_dp_trace_ptr_buf - pointer record buffer
257  * @cookie: cookie value
258  * @msdu_id: msdu_id
259  * @status: completion status
260  */
261 struct qdf_dp_trace_ptr_buf {
262 	uint64_t cookie;
263 	uint16_t msdu_id;
264 	uint16_t status;
265 };
266 
267 /**
268  * struct qdf_dp_trace_proto_buf - proto packet buffer
269  * @sa: source address
270  * @da: destination address
271  * @vdev_id : vdev id
272  * @type: packet type
273  * @subtype: packet subtype
274  * @dir: direction
275  */
276 struct qdf_dp_trace_proto_buf {
277 	struct qdf_mac_addr sa;
278 	struct qdf_mac_addr da;
279 	uint8_t vdev_id;
280 	uint8_t type;
281 	uint8_t subtype;
282 	uint8_t dir;
283 };
284 
285 /**
286  * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer
287  * @vdev_id : vdev id
288  * @type: packet type
289  * @subtype: packet subtype
290  */
291 struct qdf_dp_trace_mgmt_buf {
292 	uint8_t vdev_id;
293 	uint8_t type;
294 	uint8_t subtype;
295 };
296 
297 /**
298  * struct qdf_dp_trace_event_buf - event buffer
299  * @vdev_id : vdev id
300  * @type: packet type
301  * @subtype: packet subtype
302  */
303 struct qdf_dp_trace_event_buf {
304 	uint8_t vdev_id;
305 	uint8_t type;
306 	uint8_t subtype;
307 };
308 
309 /**
310  * struct qdf_dp_trace_record_s - Describes a record in DP trace
311  * @time: time when it got stored
312  * @code: Describes the particular event
313  * @data: buffer to store data
314  * @size: Length of the valid data stored in this record
315  * @pid : process id which stored the data in this record
316  */
317 struct qdf_dp_trace_record_s {
318 	char time[20];
319 	uint8_t code;
320 	uint8_t data[QDF_DP_TRACE_RECORD_SIZE];
321 	uint8_t size;
322 	uint32_t pid;
323 	uint8_t pdev_id;
324 };
325 
326 /**
327  * struct qdf_dp_trace_data - Parameters to configure/control DP trace
328  * @head: Position of first record
329  * @tail: Position of last record
330  * @num:  Current index
331  * @proto_bitmap: defines which protocol to be traced
332  * @no_of_record: defines every nth packet to be traced
333  * @verbosity : defines verbosity level
334  * @enable: enable/disable DP trace
335  * @count: current packet number
336  */
337 struct s_qdf_dp_trace_data {
338 	uint32_t head;
339 	uint32_t tail;
340 	uint32_t num;
341 	uint8_t proto_bitmap;
342 	uint8_t no_of_record;
343 	uint8_t verbosity;
344 	bool enable;
345 	uint32_t tx_count;
346 	uint32_t rx_count;
347 	bool live_mode;
348 };
349 
350 
351 /* Function declarations and documenation */
352 
353 /**
354  * qdf_trace_set_level() - Set the trace level for a particular module
355  * @level : trace level
356  *
357  * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating
358  * the severity of the condition causing the trace message to be issued.
359  * More severe conditions are more likely to be logged.
360  *
361  * This is an external API that allows trace levels to be set for each module.
362  *
363  * Return:  nothing
364  */
365 void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
366 
367 /**
368  * qdf_trace_get_level() - get the trace level
369  * @level : trace level
370  *
371  * This is an external API that returns a bool value to signify if a
372  * particular trace level is set for the specified module.
373  * A member of the QDF_TRACE_LEVEL enumeration indicating the severity
374  * of the condition causing the trace message to be issued.
375  *
376  * Note that individual trace levels are the only valid values
377  * for this API.  QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL
378  * are not valid input and will return false
379  *
380  * Return:
381  *  false - the specified trace level for the specified module is OFF
382  *  true - the specified trace level for the specified module is ON
383  */
384 bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level);
385 
386 typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t);
387 typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size);
388 void qdf_register_debugcb_init(void);
389 void qdf_register_debug_callback(QDF_MODULE_ID module_id,
390 					tp_qdf_state_info_cb qdf_state_infocb);
391 QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
392 			uint16_t *driver_dump_size);
393 void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb);
394 QDF_STATUS qdf_trace_spin_lock_init(void);
395 void qdf_trace_init(void);
396 void qdf_trace_enable(uint32_t, uint8_t enable);
397 void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t);
398 
399 
400 #ifdef CONFIG_DP_TRACE
401 void qdf_dp_set_proto_bitmap(uint32_t val);
402 void qdf_dp_trace_set_verbosity(uint32_t val);
403 void qdf_dp_set_no_of_record(uint32_t val);
404 void qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
405 				enum qdf_proto_dir dir, uint8_t pdev_id);
406 void qdf_dp_trace_init(void);
407 void qdf_dp_trace_spin_lock_init(void);
408 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
409 			 uint8_t verbosity);
410 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir);
411 void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id,
412 			uint8_t *data, uint8_t size, enum qdf_proto_dir dir);
413 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id);
414 typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*,
415 				uint16_t, uint8_t);
416 void qdf_dp_display_record(struct qdf_dp_trace_record_s *record,
417 					uint16_t index, uint8_t pdev_id);
418 void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code,
419 	uint8_t pdev_id, uint8_t *data, uint8_t size, uint16_t msdu_id,
420 	uint16_t status);
421 
422 void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *pRecord,
423 				uint16_t recIndex, uint8_t pdev_id);
424 uint8_t qdf_dp_get_proto_bitmap(void);
425 uint8_t qdf_dp_get_verbosity(void);
426 uint8_t qdf_dp_get_no_of_record(void);
427 void
428 qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
429 	uint8_t *sa, uint8_t *da, enum qdf_proto_type type,
430 	enum qdf_proto_subtype subtype, enum qdf_proto_dir dir,
431 	uint8_t pdev_id);
432 void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record,
433 				uint16_t index, uint8_t pdev_id);
434 void qdf_dp_trace_enable_live_mode(void);
435 void qdf_dp_trace_clear_buffer(void);
436 void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
437 	uint8_t pdev_id, enum qdf_proto_type type,
438 	enum qdf_proto_subtype subtype);
439 void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record,
440 			      uint16_t index, uint8_t pdev_id);
441 void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record,
442 			      uint16_t index, uint8_t pdev_id);
443 void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id,
444 	uint8_t pdev_id, enum qdf_proto_type type,
445 	enum qdf_proto_subtype subtype);
446 #else
447 static inline
448 void qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb,
449 				enum qdf_proto_dir dir, uint8_t pdev_id)
450 {
451 }
452 static inline
453 void qdf_dp_trace_init(void)
454 {
455 }
456 static inline
457 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
458 {
459 }
460 static inline
461 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records,
462 			 uint8_t verbosity)
463 {
464 }
465 static inline
466 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id)
467 {
468 }
469 
470 static inline
471 void qdf_dp_trace_enable_live_mode(void)
472 {
473 }
474 
475 static inline
476 void qdf_dp_trace_clear_buffer(void)
477 {
478 }
479 
480 #endif
481 
482 
483 
484 void qdf_trace_display(void);
485 
486 void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
487 			 uint8_t on);
488 
489 void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level);
490 
491 void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size,
492 		  char *str_format, ...);
493 
494 #define QDF_SNPRINTF qdf_snprintf
495 
496 #ifdef TSOSEG_DEBUG
497 static inline
498 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
499 			   uint16_t caller)
500 {
501 	int rc = -1;
502 
503 	if (tsoseg != NULL) {
504 		tsoseg->dbg.cur++;  tsoseg->dbg.cur &= 0x0f;
505 		tsoseg->dbg.history[tsoseg->dbg.cur] = caller;
506 		rc = tsoseg->dbg.cur;
507 	}
508 	return rc;
509 };
510 static inline void qdf_tso_seg_dbg_bug(char *msg)
511 {
512 	qdf_print(msg);
513 	QDF_BUG(0);
514 };
515 
516 static inline void
517 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
518 {
519 	tsoseg->dbg.txdesc = owner;
520 };
521 
522 static inline void
523 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
524 {
525 	memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg));
526 	return;
527 };
528 
529 #else
530 static inline
531 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg,
532 			   uint16_t caller)
533 {
534 	return 0;
535 };
536 static inline void qdf_tso_seg_dbg_bug(char *msg)
537 {
538 };
539 static inline void
540 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner)
541 {
542 };
543 static inline int
544 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg)
545 {
546 	memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t));
547 	return 0;
548 };
549 
550 #endif /* TSOSEG_DEBUG */
551 
552 void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level,
553 			void *data, int buf_len);
554 
555 #define ERROR_CODE                      -1
556 #define QDF_MAX_NAME_SIZE               32
557 #define MAX_PRINT_CONFIG_SUPPORTED      32
558 
559 #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX
560 
561 /**
562  * qdf_set_pidx() - Sets the global qdf_pidx.
563  * @pidx : Index of print control object assigned to the module
564  *
565  */
566 void qdf_set_pidx(int pidx);
567 
568 /**
569  * qdf_get_pidx() - Returns the global qdf_pidx.
570  *
571  * Return : Current qdf print index.
572  */
573 int qdf_get_pidx(void);
574 /*
575  * Shared print control index
576  * for converged debug framework
577  */
578 
579 #define QDF_PRINT_IDX_SHARED -1
580 
581 /**
582  * QDF_PRINT_INFO() - Generic wrapper API for logging
583  * @idx : Index of print control object
584  * @module : Module identifier. A member of QDF_MODULE_ID enumeration that
585  *           identifies the module issuing the trace message
586  * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating
587  *          the severity of the condition causing the trace message to be
588  *          issued.
589  * @str_format : Format string that contains the message to be logged.
590  *
591  *
592  * This wrapper will be used for any generic logging messages. Wrapper will
593  * compile a call to converged QDF trace message API.
594  *
595  * Return : Nothing
596  *
597  */
598 void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module,
599 		    QDF_TRACE_LEVEL level,
600 		    char *str_format, ...);
601 
602 /**
603  * struct category_info  : Category information structure
604  * @category_verbose_mask: Embeds information about category's verbose level
605  */
606 struct category_info {
607 	uint16_t category_verbose_mask;
608 };
609 
610 /**
611  * struct category_name_info  : Category name information structure
612  * @category_name_str: Embeds information about category name
613  */
614 struct category_name_info {
615 	unsigned char category_name_str[QDF_MAX_NAME_SIZE];
616 };
617 
618 /**
619  * qdf_trace_msg_cmn()- Converged logging API
620  * @idx: Index of print control object assigned to the module
621  * @category: Category identifier. A member of the QDF_MODULE_ID enumeration
622  *            that identifies the category issuing the trace message.
623  * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration
624  *           indicating the severity of the condition causing the trace
625  *           message to be issued. More severe conditions are more likely
626  *           to be logged.
627  * @str_format: Format string. The message to be logged. This format string
628  *              contains printf-like replacement parameters, which follow this
629  *              parameter in the variable argument list.
630  * @val: Variable argument list part of the log message
631  *
632  * Return: nothing
633  *
634  */
635 void qdf_trace_msg_cmn(unsigned int idx,
636 			QDF_MODULE_ID category,
637 			QDF_TRACE_LEVEL verbose,
638 			const char *str_format,
639 			va_list val);
640 
641 /**
642  * struct qdf_print_ctrl: QDF Print Control structure
643  *                        Statically allocated objects of print control
644  *                        structure are declared that will support maximum of
645  *                        32 print control objects. Any module that needs to
646  *                        register to the print control framework needs to
647  *                        obtain a print control object using
648  *                        qdf_print_ctrl_register API. It will have to pass
649  *                        pointer to category info structure, name and
650  *                        custom print function to be used if required.
651  * @name                : Optional name for the control object
652  * @cat_info            : Array of category_info struct
653  * @custom_print        : Custom print handler
654  * @custom_ctxt         : Custom print context
655  * @dbglvlmac_on        : Flag to enable/disable MAC level filtering
656  * @in_use              : Boolean to indicate if control object is in use
657  */
658 struct qdf_print_ctrl {
659 	char name[QDF_MAX_NAME_SIZE];
660 	struct category_info cat_info[MAX_SUPPORTED_CATEGORY];
661 	void (*custom_print)(void *ctxt, const char *fmt, va_list args);
662 	void *custom_ctxt;
663 #ifdef DBG_LVL_MAC_FILTERING
664 	unsigned char dbglvlmac_on;
665 #endif
666 	bool in_use;
667 };
668 
669 /**
670  * qdf_print_ctrl_register() - Allocate QDF print control object, assign
671  *                             pointer to category info or print control
672  *                             structure and return the index to the callee
673  * @cinfo                 : Pointer to array of category info structure
674  * @custom_print_handler  : Pointer to custom print handler
675  * @custom_ctx            : Pointer to custom context
676  * @pctrl_name            : Pointer to print control object name
677  *
678  * Return                 : Index of qdf_print_ctrl structure
679  *
680  */
681 int qdf_print_ctrl_register(const struct category_info *cinfo,
682 			    void *custom_print_handler,
683 			    void *custom_ctx,
684 			    const char *pctrl_name);
685 
686 /**
687  * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with
688  *                                all categories set to the default level
689  *
690  * Return                 : void
691  *
692  */
693 void qdf_shared_print_ctrl_init(void);
694 
695 /**
696  * qdf_print_setup() - Setup default values to all the print control objects
697  *
698  * Register new print control object for the callee
699  *
700  * Return :             QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE
701  *                      on failure
702  */
703 QDF_STATUS qdf_print_setup(void);
704 
705 /**
706  * qdf_print_ctrl_cleanup() - Clean up a print control object
707  *
708  * Cleanup the print control object for the callee
709  *
710  * @pctrl : Index of print control object
711  *
712  * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
713  */
714 QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx);
715 
716 /**
717  * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object
718  *
719  * Cleanup the shared print-ctrl-object
720  *
721  * Return : void
722  */
723 void qdf_shared_print_ctrl_cleanup(void);
724 
725 /**
726  * qdf_print_set_category_verbose() - Enable/Disable category for a
727  *                                    print control object with
728  *                                    user provided verbose level
729  *
730  * @idx : Index of the print control object assigned to callee
731  * @category : Category information
732  * @verbose: Verbose information
733  * @is_set: Flag indicating if verbose level needs to be enabled or disabled
734  *
735  * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
736  */
737 QDF_STATUS qdf_print_set_category_verbose(unsigned int idx,
738 					  QDF_MODULE_ID category,
739 					  QDF_TRACE_LEVEL verbose,
740 					  bool is_set);
741 
742 /**
743  * qdf_print_is_category_enabled() - Get category information for the
744  *                                   print control object
745  *
746  * @idx : Index of print control object
747  * @category : Category information
748  *
749  * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
750  */
751 bool qdf_print_is_category_enabled(unsigned int idx,
752 				   QDF_MODULE_ID category);
753 
754 /**
755  * qdf_print_is_verbose_enabled() - Get verbose information of a category for
756  *                                  the print control object
757  *
758  * @idx : Index of print control object
759  * @category : Category information
760  * @verbose : Verbose information
761  *
762  * Return : Verbose enabled(true) or disabled(false) or invalid input (false)
763  */
764 bool qdf_print_is_verbose_enabled(unsigned int idx,
765 				  QDF_MODULE_ID category,
766 				  QDF_TRACE_LEVEL verbose);
767 
768 /**
769  * qdf_print_clean_node_flag() - Clean up node flag for print control object
770  *
771  * @idx : Index of print control object
772  *
773  * Return : None
774  */
775 void qdf_print_clean_node_flag(unsigned int idx);
776 
777 #ifdef DBG_LVL_MAC_FILTERING
778 
779 /**
780  * qdf_print_set_node_flag() - Set flag to enable MAC level filtering
781  *
782  * @idx : Index of print control object
783  * @enable : Enable/Disable bit sent by callee
784  *
785  * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure
786  */
787 QDF_STATUS qdf_print_set_node_flag(unsigned int idx,
788 				   uint8_t enable);
789 
790 /**
791  * qdf_print_get_node_flag() - Get flag that controls MAC level filtering
792  *
793  * @idx : Index of print control object
794  *
795  * Return : Flag that indicates enable(1) or disable(0) or invalid(-1)
796  */
797 bool qdf_print_get_node_flag(unsigned int idx);
798 
799 #endif
800 
801 /**
802  * qdf_logging_init() - Initialize msg logging functionality
803  *
804  *
805  * Return : void
806  */
807 void qdf_logging_init(void);
808 
809 /**
810  * qdf_logging_exit() - Cleanup msg logging functionality
811  *
812  *
813  * Return : void
814  */
815 void qdf_logging_exit(void);
816 
817 #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN
818 
819 /**
820  * qdf_sprint_symbol() - prints the name of a symbol into a string buffer
821  * @buffer: the string buffer to print into
822  * @addr: address of the symbol to lookup and print
823  *
824  * Return: number of characters printed
825  */
826 int qdf_sprint_symbol(char *buffer, void *addr);
827 
828 #endif /* __QDF_TRACE_H */
829