1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 17 * 18 * 19 ******************************************************************************/ 20 21 22 #ifndef __ODM_DBG_H__ 23 #define __ODM_DBG_H__ 24 25 /*#define DEBUG_VERSION "1.1"*/ /*2015.07.29 YuChen*/ 26 /*#define DEBUG_VERSION "1.2"*/ /*2015.08.28 Dino*/ 27 #define DEBUG_VERSION "1.3" /*2016.04.28 YuChen*/ 28 //----------------------------------------------------------------------------- 29 // Define the debug levels 30 // 31 // 1. DBG_TRACE and DBG_LOUD are used for normal cases. 32 // So that, they can help SW engineer to develope or trace states changed 33 // and also help HW enginner to trace every operation to and from HW, 34 // e.g IO, Tx, Rx. 35 // 36 // 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, 37 // which help us to debug SW or HW. 38 // 39 //----------------------------------------------------------------------------- 40 // 41 // Never used in a call to ODM_RT_TRACE()! 42 // 43 #define ODM_DBG_OFF 1 44 45 // 46 // Fatal bug. 47 // For example, Tx/Rx/IO locked up, OS hangs, memory access violation, 48 // resource allocation failed, unexpected HW behavior, HW BUG and so on. 49 // 50 #define ODM_DBG_SERIOUS 2 51 52 // 53 // Abnormal, rare, or unexpeted cases. 54 // For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. 55 // 56 #define ODM_DBG_WARNING 3 57 58 // 59 // Normal case with useful information about current SW or HW state. 60 // For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status, 61 // SW protocol state change, dynamic mechanism state change and so on. 62 // 63 #define ODM_DBG_LOUD 4 64 65 // 66 // Normal case with detail execution flow or information. 67 // 68 #define ODM_DBG_TRACE 5 69 70 /*FW DBG MSG*/ 71 #define RATE_DECISION BIT0 72 #define INIT_RA_TABLE BIT1 73 #define RATE_UP BIT2 74 #define RATE_DOWN BIT3 75 #define TRY_DONE BIT4 76 #define RA_H2C BIT5 77 #define F_RATE_AP_RPT BIT7 78 79 //----------------------------------------------------------------------------- 80 // Define the tracing components 81 // 82 //----------------------------------------------------------------------------- 83 //BB Functions 84 #define ODM_COMP_DIG BIT0 85 #define ODM_COMP_RA_MASK BIT1 86 #define ODM_COMP_DYNAMIC_TXPWR BIT2 87 #define ODM_COMP_FA_CNT BIT3 88 #define ODM_COMP_RSSI_MONITOR BIT4 89 #define ODM_COMP_SNIFFER BIT5 90 #define ODM_COMP_ANT_DIV BIT6 91 #define ODM_COMP_DFS BIT7 92 #define ODM_COMP_NOISY_DETECT BIT8 93 #define ODM_COMP_RATE_ADAPTIVE BIT9 94 #define ODM_COMP_PATH_DIV BIT10 95 #define ODM_COMP_CCX BIT11 96 97 #define ODM_COMP_DYNAMIC_PRICCA BIT12 98 /*BIT13 TBD*/ 99 #define ODM_COMP_MP BIT14 100 #define ODM_COMP_CFO_TRACKING BIT15 101 #define ODM_COMP_ACS BIT16 102 #define PHYDM_COMP_ADAPTIVITY BIT17 103 #define PHYDM_COMP_RA_DBG BIT18 104 #define PHYDM_COMP_TXBF BIT19 105 //MAC Functions 106 #define ODM_COMP_EDCA_TURBO BIT20 107 /*BIT21 TBD*/ 108 #define ODM_FW_DEBUG_TRACE BIT22 109 //RF Functions 110 /*BIT23 TBD*/ 111 #define ODM_COMP_TX_PWR_TRACK BIT24 112 #define ODM_COMP_RX_GAIN_TRACK BIT25 113 #define ODM_COMP_CALIBRATION BIT26 114 //Common Functions 115 #define ODM_PHY_CONFIG BIT28 116 #define ODM_COMP_INIT BIT29 117 #define ODM_COMP_COMMON BIT30 118 #define ODM_COMP_API BIT31 119 120 121 /*------------------------Export Marco Definition---------------------------*/ 122 123 #define config_phydm_read_txagc_check(data) (data != INVALID_TXAGC_DATA) 124 125 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) 126 #define RT_PRINTK DbgPrint 127 #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) 128 #define DbgPrint printk 129 #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args); 130 #define RT_DISP(dbgtype, dbgflag, printstr) 131 #else 132 #define DbgPrint panic_printk 133 #define RT_PRINTK(fmt, args...) DbgPrint( "%s(): " fmt, __FUNCTION__, ## args); 134 #endif 135 136 #ifndef ASSERT 137 #define ASSERT(expr) 138 #endif 139 140 #if DBG 141 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ 142 do { \ 143 if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS)) \ 144 { \ 145 if (pDM_Odm->SupportICType == ODM_RTL8188E) \ 146 DbgPrint("[PhyDM-8188E] "); \ 147 else if(pDM_Odm->SupportICType == ODM_RTL8192E) \ 148 DbgPrint("[PhyDM-8192E] "); \ 149 else if(pDM_Odm->SupportICType == ODM_RTL8812) \ 150 DbgPrint("[PhyDM-8812A] "); \ 151 else if(pDM_Odm->SupportICType == ODM_RTL8821) \ 152 DbgPrint("[PhyDM-8821A] "); \ 153 else if(pDM_Odm->SupportICType == ODM_RTL8814A) \ 154 DbgPrint("[PhyDM-8814A] "); \ 155 else if(pDM_Odm->SupportICType == ODM_RTL8703B) \ 156 DbgPrint("[PhyDM-8703B] "); \ 157 else if(pDM_Odm->SupportICType == ODM_RTL8822B) \ 158 DbgPrint("[PhyDM-8822B] "); \ 159 else if (pDM_Odm->SupportICType == ODM_RTL8188F) \ 160 DbgPrint("[PhyDM-8188F] "); \ 161 RT_PRINTK fmt; \ 162 } \ 163 } while (0) 164 165 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ 166 if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ 167 { \ 168 RT_PRINTK fmt; \ 169 } 170 171 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ 172 if(!(expr)) { \ 173 DbgPrint( "Assertion failed! %s at ......\n", #expr); \ 174 DbgPrint( " ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__); \ 175 RT_PRINTK fmt; \ 176 ASSERT(FALSE); \ 177 } 178 #define ODM_dbg_enter() { DbgPrint("==> %s\n", __FUNCTION__); } 179 #define ODM_dbg_exit() { DbgPrint("<== %s\n", __FUNCTION__); } 180 #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __FUNCTION__, str); } 181 182 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ 183 if(((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ 184 { \ 185 int __i; \ 186 pu1Byte __ptr = (pu1Byte)ptr; \ 187 DbgPrint("[ODM] "); \ 188 DbgPrint(title_str); \ 189 DbgPrint(" "); \ 190 for( __i=0; __i<6; __i++ ) \ 191 DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-"); \ 192 DbgPrint("\n"); \ 193 } 194 #else 195 #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) 196 #define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) 197 #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) 198 #define ODM_dbg_enter() 199 #define ODM_dbg_exit() 200 #define ODM_dbg_trace(str) 201 #define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) 202 #endif 203 204 205 VOID 206 PHYDM_InitDebugSetting(IN PDM_ODM_T pDM_Odm); 207 208 VOID phydm_BasicDbgMessage( IN PVOID pDM_VOID); 209 210 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) 211 #define PHYDM_DBGPRINT 0 212 #define PHYDM_SSCANF(x, y, z) DCMD_Scanf(x, y, z) 213 #define PHYDM_VAST_INFO_SNPRINTF PHYDM_SNPRINTF 214 #if (PHYDM_DBGPRINT == 1) 215 #define PHYDM_SNPRINTF(msg) \ 216 do {\ 217 rsprintf msg;\ 218 DbgPrint(output);\ 219 } while (0) 220 #else 221 #define PHYDM_SNPRINTF(msg) \ 222 do {\ 223 rsprintf msg;\ 224 DCMD_Printf(output);\ 225 } while (0) 226 #endif 227 #else 228 #if (DM_ODM_SUPPORT_TYPE == ODM_CE) || defined(__OSK__) 229 #define PHYDM_DBGPRINT 0 230 #else 231 #define PHYDM_DBGPRINT 1 232 #endif 233 #define MAX_ARGC 20 234 #define MAX_ARGV 16 235 #define DCMD_DECIMAL "%d" 236 #define DCMD_CHAR "%c" 237 #define DCMD_HEX "%x" 238 239 #define PHYDM_SSCANF(x, y, z) sscanf(x, y, z) 240 241 #define PHYDM_VAST_INFO_SNPRINTF(msg)\ 242 do {\ 243 snprintf msg;\ 244 DbgPrint(output);\ 245 } while (0) 246 247 #if (PHYDM_DBGPRINT == 1) 248 #define PHYDM_SNPRINTF(msg)\ 249 do {\ 250 snprintf msg;\ 251 DbgPrint(output);\ 252 } while (0) 253 #else 254 #define PHYDM_SNPRINTF(msg)\ 255 do {\ 256 if(out_len > used)\ 257 used+=snprintf msg;\ 258 } while (0) 259 #endif 260 #endif 261 262 263 VOID phydm_BasicProfile( 264 IN PVOID pDM_VOID, 265 IN u4Byte *_used, 266 OUT char *output, 267 IN u4Byte *_out_len 268 ); 269 #if(DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_AP)) 270 s4Byte 271 phydm_cmd( 272 IN PDM_ODM_T pDM_Odm, 273 IN char *input, 274 IN u4Byte in_len, 275 IN u1Byte flag, 276 OUT char *output, 277 IN u4Byte out_len 278 ); 279 #endif 280 VOID 281 phydm_cmd_parser( 282 IN PDM_ODM_T pDM_Odm, 283 IN char input[][16], 284 IN u4Byte input_num, 285 IN u1Byte flag, 286 OUT char *output, 287 IN u4Byte out_len 288 ); 289 290 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) 291 void phydm_sbd_check( 292 IN PDM_ODM_T pDM_Odm 293 ); 294 295 void phydm_sbd_callback( 296 PRT_TIMER pTimer 297 ); 298 299 void phydm_sbd_workitem_callback( 300 IN PVOID pContext 301 ); 302 #endif 303 304 VOID 305 phydm_fw_trace_en_h2c( 306 IN PVOID pDM_VOID, 307 IN BOOLEAN enable, 308 IN u4Byte monitor_mode, 309 IN u4Byte macid 310 ); 311 312 VOID 313 phydm_fw_trace_handler( 314 IN PVOID pDM_VOID, 315 IN pu1Byte CmdBuf, 316 IN u1Byte CmdLen 317 ); 318 319 VOID 320 phydm_fw_trace_handler_code( 321 IN PVOID pDM_VOID, 322 IN pu1Byte Buffer, 323 IN u1Byte CmdLen 324 ); 325 326 VOID 327 phydm_fw_trace_handler_8051( 328 IN PVOID pDM_VOID, 329 IN pu1Byte CmdBuf, 330 IN u1Byte CmdLen 331 ); 332 333 #endif // __ODM_DBG_H__ 334 335