1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 
8 #ifndef	__ODM_DBG_H__
9 #define __ODM_DBG_H__
10 
11 /*  */
12 /*	Define the debug levels */
13 /*  */
14 /*	1. DBG_TRACE and DBG_LOUD are used for normal cases. */
15 /*	They can help SW engineer to develop or trace states changed */
16 /*	and also help HW enginner to trace every operation to and from HW, */
17 /*	e.g IO, Tx, Rx. */
18 /*  */
19 /*	2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */
20 /*	which help us to debug SW or HW. */
21 
22 /*	Never used in a call to ODM_RT_TRACE()! */
23 #define ODM_DBG_OFF				1
24 
25 /*	Fatal bug. */
26 /*	For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */
27 /*	resource allocation failed, unexpected HW behavior, HW BUG and so on. */
28 #define ODM_DBG_SERIOUS				2
29 
30 /*	Abnormal, rare, or unexpected cases. */
31 /*	For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. */
32 #define ODM_DBG_WARNING				3
33 
34 /*	Normal case with useful information about current SW or HW state. */
35 /*	For example, Tx/Rx descriptor to fill, Tx/Rx descr. completed status, */
36 /*	SW protocol state change, dynamic mechanism state change and so on. */
37 /*  */
38 #define ODM_DBG_LOUD					4
39 
40 /*	Normal case with detail execution flow or information. */
41 #define ODM_DBG_TRACE					5
42 
43 /*  Define the tracing components */
44 /* BB Functions */
45 #define ODM_COMP_DIG					BIT(0)
46 #define ODM_COMP_RA_MASK				BIT(1)
47 #define ODM_COMP_DYNAMIC_TXPWR				BIT(2)
48 #define ODM_COMP_FA_CNT					BIT(3)
49 #define ODM_COMP_RSSI_MONITOR				BIT(4)
50 #define ODM_COMP_CCK_PD					BIT(5)
51 #define ODM_COMP_ANT_DIV				BIT(6)
52 #define ODM_COMP_PWR_SAVE				BIT(7)
53 #define ODM_COMP_PWR_TRA				BIT(8)
54 #define ODM_COMP_RATE_ADAPTIVE				BIT(9)
55 #define ODM_COMP_PATH_DIV				BIT(10)
56 #define ODM_COMP_PSD					BIT(11)
57 #define ODM_COMP_DYNAMIC_PRICCA				BIT(12)
58 #define ODM_COMP_RXHP					BIT(13)
59 /* MAC Functions */
60 #define ODM_COMP_EDCA_TURBO				BIT(16)
61 #define ODM_COMP_EARLY_MODE				BIT(17)
62 /* RF Functions */
63 #define ODM_COMP_TX_PWR_TRACK				BIT(24)
64 #define ODM_COMP_RX_GAIN_TRACK				BIT(25)
65 #define ODM_COMP_CALIBRATION				BIT(26)
66 /* Common Functions */
67 #define ODM_COMP_COMMON					BIT(30)
68 #define ODM_COMP_INIT					BIT(31)
69 
70 /*------------------------Export Marco Definition---------------------------*/
71 #define RT_PRINTK(fmt, args...)				\
72 	pr_info("%s(): " fmt, __func__, ## args);
73 
74 #ifndef ASSERT
75 	#define ASSERT(expr)
76 #endif
77 
78 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)				\
79 	if (((comp) & pDM_Odm->DebugComponents) &&			\
80 	    (level <= pDM_Odm->DebugLevel)) {				\
81 		pr_info("[ODM-8188E] ");				\
82 		RT_PRINTK fmt;						\
83 	}
84 
85 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt)				\
86 	if (!(expr)) {							\
87 		pr_info("Assertion failed! %s at ......\n", #expr);	\
88 		pr_info("      ......%s,%s,line=%d\n", __FILE__,	\
89 			__func__, __LINE__);				\
90 		RT_PRINTK fmt;						\
91 		ASSERT(false);						\
92 	}
93 
94 void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm);
95 
96 #endif	/*  __ODM_DBG_H__ */
97