A.) debug interface (commands)

iwpriv wlan0 dbg 0x70XXYYYY 0  // MAC reg read
iwpriv wlan0 dbg 0x71XXYYYY 0  // MAC reg write
 
 XX -  01,02,04 (bytes)
 YYYY - MAC reg offset ( 0x000 ~ 0x7ff )
 ---------------------------------------------------
 ex:
 1.) read MAC ID
 iwpriv wlan0 dbg 0x70040610 0
 iwpriv wlan0 dbg 0x70040614 0
 
 [drv_log]: rtw_read32(0x610)=0x814ce000 
 [drv_log]: rtw_read16(0x614)=0x76 
 => MAC ID = 00:e0:4c:81:76:00
 
 2.) modify MAC ID
 iwpriv wlan0 dbg 0x71040614 0x1176
 [drv_log]: rtw_write16(0x614)=0x1176 
 => MAC ID = 00:e0:4c:81:76:11

//======================================================
iwpriv wlan0 dbg 0x7200YYYY 0  // BB reg read
iwpriv wlan0 dbg 0x7300YYYY 0  // BB reg write
 
 YYYY - BB reg offset ( 0x800 ~ ??)
 ---------------------------------------------------
 
 ex: 
 1.) read initial gain
 iwpriv wlan0 dbg 0x72000c50 0
 [drv_log]: read_bbreg(0xc50)=0x6954341e
 
 also read bb reg via MAC reg read
 => iwpriv wlan0 dbg 0x70010c50 
  
 2.) modify initial gain
 iwpriv wlan0 dbg 0x73000c50 0x0x69543420
 [drv_log]: write_bbreg(0xc50)=0x6954320
 
 also modify bb reg via MAC reg read
 => iwpriv wlan0 dbg 0x71010c50 0x20 

//======================================================
iwpriv wlan0 dbg 0x74XXYYYY 0  // RF reg read
iwpriv wlan0 dbg 0x75XXYYYY 0  // RF reg write
 
 XX - RF path (from 0 to 1)
 YYYY - RF reg offset
 ---------------------------------------------------
 
 ex:
 1.) read RF path 0 status
 iwpriv wlan0 dbg 0x74000000 0 
 [drv_log]: read RF_reg path(0x00),offset(0x0),value(0x00030db4)
 
 2.) read RF path 1 status
 iwpriv wlan0 dbg 0x74010000 0 
 [drv_log]: read RF_reg path(0x01),offset(0x0),value(0x00000000)
 
 
 //======================================================
 iwpriv wlan0 dbg 0x7FXXYYYY ZZ
 
 1.) XX = 0x00 ,get fw state
 ex: iwpriv wlan0 dbg 0x7f000000 0
 [drv_log]: fwstate=0x08
 
 2.) XX = 0x01 ,get current security setting (get info from securitypriv)
 ex: iwpriv wlan0 dbg 0x7f010000 0
 [drv_log]: auth_alg=0x0, enc_alg=0x0, auth_type=0x0, enc_type=0x1
 
 3.) XX = 0x02 ,get mlmeinfo->state
  ex: iwpriv wlan0 dbg 0x7f020000 0
  [drv_log]: pmlmeinfo->state=0x0
  
 4.) XX = 0x03 ,get options (get info from pmlmepriv->qospriv.qos_option/pmlmepriv->htpriv.ht_option)
  ex: iwpriv wlan0 dbg 0x7f030000 0
  [drv_log]:qos_optioin=1,ht_option=0
  
 5.) XX = 0x04 ,get current channel and bandwidth
  ex: iwpriv wlan0 dbg 0x7f040000 0
  [drv_log]: cur_ch=3,cur_bw=0,cur_ch_off=0
  
 6.) XX = 0x05 ,get sta info,In station mode, those info will be currently connected AP's setting.
  ex: iwpriv wlan0 dbg 0x7f050000 0
  [drv_log]: 
  sta's macaddr:00:0a:79:ba:8d:53 (it will be AP's macaddr in station mode )
  rtsen=0, cts2self=0
  qos_en=1,ht_en=0, init_rate=11
  state=0x1, aid=1, macid=0,raid=4
  bwmode=0, ch_offset=0, sgi=0
  ampdu_enable=0
  agg_enable_bitmap=0, candidate_tid_bitmap=0
 
 7.) XX = 0x07, get current setting of bSurpriseRemoved, bDriverStopped
  ex: iwpriv wlan0 dbg 0x7f070000 0
  [drv_log]: bSurpriseRemoved=0, bDriverStopped=0
 
 8.) XX = 0x08, get current setting of pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt,rx_urb_pending_cn
  ex: iwpriv wlan0 dbg 0x7f080000 0
  [drv_log]:free_xmitbuf_cnt=4, free_xmitframe_cnt=256,rx_urb_pending_cn=5
  
 9.) XX = 0x10, get driver version
 	ex: iwpriv wlan0 dbg 0x7f100000 0
	[drv_log]:rtw driver version=v3.0.2385.20110826
	
 10.) XX = 0x11, dump linked info 
  ex: 
  		iwpriv wlan0 dbg 0x7f110000 0 //disable linked info dump
  		iwpriv wlan0 dbg 0x7f110000 0x1 //RA info dump
  		iwpriv wlan0 dbg 0x7f110000 0x2 //DIG info dump
  		iwpriv wlan0 dbg 0x7f110000 0x4 //FA info dump
 	 		iwpriv wlan0 dbg 0x7f110000 0xFF //dump	all info
 
 11.) XX = 0x0c,dump rx/tx info or packet
 			YY = 0: dump rx packet,
 			ZZ = 1: dump all rx frames, 2:dump management frames, 3: dump data frames
 			
 			YY =1: dump tx desc	
 			ZZ = 1:dump txdesc of data frame , 2:dump txdesc of mgnt frame, 3:dump early info 			
  ex: 
  		iwpriv wlan0 dbg 0x7f0c0001 1 //dump data frame's tx_desc
  		iwpriv wlan0 dbg 0x7f0c0000 3 //dump rx data frame
 
 12.) XX = 0x0f, silent reset test
 13.) XX = 0x15, get silent reset counts.
 
 14.) XX = 0x16,get or set pDM_Odm->DebugComponents
 			YY = 0xff , got help
 			YY = 0, ZZ ,open debug message of ODM by change pDM_Odm->DebugComponents
  					
 14.) XX = 0xdd, registers dump , 0 for mac reg,1 for bb reg, 2 for rf reg
  ex: iwpriv wlan0 dbg 0x7fdd0000 0  //dump mac reg
  ex: iwpriv wlan0 dbg 0x7fdd0000 1  //dump bb reg
  ex: iwpriv wlan0 dbg 0x7fdd0000 2  //dump rf reg
 				

	15.) XX = 0xfd, modify initial gain(0xc50,0xc58),	
	     XX = 0xfe, read initial gain(0xc50,0xc58)					
 	ex: iwpriv wlan0 dbg 0x7ffd0000 0x20  
 	[drv_log]: wr(0xc50)=0x20 , wr(0xc58)=0x20
	
	ex: iwpriv wlan0 dbg 0x7ffe0000 0  
 	[drv_log]: rd(0xc50)=0x20 , rd(0xc58)=0x20
	
	16.) XX = 0xff,	dump some critical reg.			
 	ex: iwpriv wlan0 dbg 0x7fff0000 0
 
 	17.) XX = 0xaa //modify 8189ES tx rate for debug
 			 ZZ= extra_arg //0x00~ 0x13 ,bit_7:0 or 1 ShortGI=0 or 1, 0xFF=> disable
 	ex: iwpriv wlan0 dbg 0x7faa0000 0x13 //fix data rate to ShortGI - MCS7 
 	ex: iwpriv wlan0 dbg 0x7faa0000 0x93 //fix data rate to LongGI - MCS7
 //====================================================================
 

 B.) Troubleshooting guide  
 Issue 1.) cannot scan AP, survey down event(0) 
 step 1. tx packet buffer check
 >> iwpriv wlan0 dbg 0x70040410 0 //MGQ_INFO 
 >> iwpriv wlan0 dbg 0x70040408 0 //BEQ_INFO
It means that MAC cannot handle packets in tx FIFO(mac hang) while the value is non-zero (or not equal to 0xff0000ff ) 
 step 2.check DMA status,report from MAC
 >> iwpriv wlan0 dbg 0x70040210 0
 step 3. rx read/write pointer check
 >> iwpriv wlan0 dbg 0x7004011c 0
 
  
 Issue 2.) external noise problems
 step 1. dump RSSI, 
 >> iwpriv wlan0 dbg 0x7f110000 1
 step 2. observe the counts of false alarm and initial gain
 step 3. disable DIG
 >> iwpriv wlan0 dbg 0x7fee0000 1
 step 4. modify initial gain for Path_A
 >> iwpriv wlan0 dbg 0x71010c50 0x20 (the range of gain is from 0x1e to 0x3e)
 step 4. modify initial gain for Path_B
 >> iwpriv wlan0 dbg 0x71010c58 0x20 (the range of gain is from 0x1e to 0x3e)
 step 5. observe the counts of false alarm and initial gain
 