rtw_debug.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2012 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. #define _RTW_DEBUG_C_
  21. #include <drv_types.h>
  22. #ifdef CONFIG_DEBUG_RTL871X
  23. u32 GlobalDebugLevel = _drv_err_;
  24. u64 GlobalDebugComponents = \
  25. _module_rtl871x_xmit_c_ |
  26. _module_xmit_osdep_c_ |
  27. _module_rtl871x_recv_c_ |
  28. _module_recv_osdep_c_ |
  29. _module_rtl871x_mlme_c_ |
  30. _module_mlme_osdep_c_ |
  31. _module_rtl871x_sta_mgt_c_ |
  32. _module_rtl871x_cmd_c_ |
  33. _module_cmd_osdep_c_ |
  34. _module_rtl871x_io_c_ |
  35. _module_io_osdep_c_ |
  36. _module_os_intfs_c_|
  37. _module_rtl871x_security_c_|
  38. _module_rtl871x_eeprom_c_|
  39. _module_hal_init_c_|
  40. _module_hci_hal_init_c_|
  41. _module_rtl871x_ioctl_c_|
  42. _module_rtl871x_ioctl_set_c_|
  43. _module_rtl871x_ioctl_query_c_|
  44. _module_rtl871x_pwrctrl_c_|
  45. _module_hci_intfs_c_|
  46. _module_hci_ops_c_|
  47. _module_hci_ops_os_c_|
  48. _module_rtl871x_ioctl_os_c|
  49. _module_rtl8712_cmd_c_|
  50. _module_hal_xmit_c_|
  51. _module_rtl8712_recv_c_ |
  52. _module_mp_ |
  53. _module_efuse_;
  54. #endif
  55. #ifdef CONFIG_PROC_DEBUG
  56. #include <rtw_version.h>
  57. int proc_get_drv_version(char *page, char **start,
  58. off_t offset, int count,
  59. int *eof, void *data)
  60. {
  61. struct net_device *dev = data;
  62. int len = 0;
  63. len += snprintf(page + len, count - len, "%s\n", DRIVERVERSION);
  64. *eof = 1;
  65. return len;
  66. }
  67. int proc_get_write_reg(char *page, char **start,
  68. off_t offset, int count,
  69. int *eof, void *data)
  70. {
  71. *eof = 1;
  72. return 0;
  73. }
  74. int proc_set_write_reg(struct file *file, const char *buffer,
  75. unsigned long count, void *data)
  76. {
  77. struct net_device *dev = (struct net_device *)data;
  78. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  79. char tmp[32];
  80. u32 addr, val, len;
  81. if (count < 3)
  82. {
  83. DBG_871X("argument size is less than 3\n");
  84. return -EFAULT;
  85. }
  86. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  87. int num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
  88. if (num != 3) {
  89. DBG_871X("invalid write_reg parameter!\n");
  90. return count;
  91. }
  92. switch(len)
  93. {
  94. case 1:
  95. rtw_write8(padapter, addr, (u8)val);
  96. break;
  97. case 2:
  98. rtw_write16(padapter, addr, (u16)val);
  99. break;
  100. case 4:
  101. rtw_write32(padapter, addr, val);
  102. break;
  103. default:
  104. DBG_871X("error write length=%d", len);
  105. break;
  106. }
  107. }
  108. return count;
  109. }
  110. static u32 proc_get_read_addr=0xeeeeeeee;
  111. static u32 proc_get_read_len=0x4;
  112. int proc_get_read_reg(char *page, char **start,
  113. off_t offset, int count,
  114. int *eof, void *data)
  115. {
  116. struct net_device *dev = data;
  117. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  118. int len = 0;
  119. if(proc_get_read_addr==0xeeeeeeee)
  120. {
  121. *eof = 1;
  122. return len;
  123. }
  124. switch(proc_get_read_len)
  125. {
  126. case 1:
  127. len += snprintf(page + len, count - len, "rtw_read8(0x%x)=0x%x\n", proc_get_read_addr, rtw_read8(padapter, proc_get_read_addr));
  128. break;
  129. case 2:
  130. len += snprintf(page + len, count - len, "rtw_read16(0x%x)=0x%x\n", proc_get_read_addr, rtw_read16(padapter, proc_get_read_addr));
  131. break;
  132. case 4:
  133. len += snprintf(page + len, count - len, "rtw_read32(0x%x)=0x%x\n", proc_get_read_addr, rtw_read32(padapter, proc_get_read_addr));
  134. break;
  135. default:
  136. len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len);
  137. break;
  138. }
  139. *eof = 1;
  140. return len;
  141. }
  142. int proc_set_read_reg(struct file *file, const char *buffer,
  143. unsigned long count, void *data)
  144. {
  145. char tmp[16];
  146. u32 addr, len;
  147. if (count < 2)
  148. {
  149. DBG_871X("argument size is less than 2\n");
  150. return -EFAULT;
  151. }
  152. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  153. int num = sscanf(tmp, "%x %x", &addr, &len);
  154. if (num != 2) {
  155. DBG_871X("invalid read_reg parameter!\n");
  156. return count;
  157. }
  158. proc_get_read_addr = addr;
  159. proc_get_read_len = len;
  160. }
  161. return count;
  162. }
  163. int proc_get_fwstate(char *page, char **start,
  164. off_t offset, int count,
  165. int *eof, void *data)
  166. {
  167. struct net_device *dev = data;
  168. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  169. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  170. int len = 0;
  171. len += snprintf(page + len, count - len, "fwstate=0x%x\n", get_fwstate(pmlmepriv));
  172. *eof = 1;
  173. return len;
  174. }
  175. int proc_get_sec_info(char *page, char **start,
  176. off_t offset, int count,
  177. int *eof, void *data)
  178. {
  179. struct net_device *dev = data;
  180. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  181. struct security_priv *psecuritypriv = &padapter->securitypriv;
  182. int len = 0;
  183. len += snprintf(page + len, count - len, "auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n",
  184. psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm,
  185. psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus);
  186. *eof = 1;
  187. return len;
  188. }
  189. int proc_get_mlmext_state(char *page, char **start,
  190. off_t offset, int count,
  191. int *eof, void *data)
  192. {
  193. struct net_device *dev = data;
  194. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  195. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  196. struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
  197. int len = 0;
  198. len += snprintf(page + len, count - len, "pmlmeinfo->state=0x%x\n", pmlmeinfo->state);
  199. *eof = 1;
  200. return len;
  201. }
  202. int proc_get_qos_option(char *page, char **start,
  203. off_t offset, int count,
  204. int *eof, void *data)
  205. {
  206. struct net_device *dev = data;
  207. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  208. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  209. int len = 0;
  210. len += snprintf(page + len, count - len, "qos_option=%d\n", pmlmepriv->qospriv.qos_option);
  211. *eof = 1;
  212. return len;
  213. }
  214. int proc_get_ht_option(char *page, char **start,
  215. off_t offset, int count,
  216. int *eof, void *data)
  217. {
  218. struct net_device *dev = data;
  219. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  220. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  221. int len = 0;
  222. #ifdef CONFIG_80211N_HT
  223. len += snprintf(page + len, count - len, "ht_option=%d\n", pmlmepriv->htpriv.ht_option);
  224. #endif //CONFIG_80211N_HT
  225. *eof = 1;
  226. return len;
  227. }
  228. int proc_get_rf_info(char *page, char **start,
  229. off_t offset, int count,
  230. int *eof, void *data)
  231. {
  232. struct net_device *dev = data;
  233. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  234. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  235. int len = 0;
  236. len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n",
  237. pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
  238. len += snprintf(page + len, count - len, "oper_ch=%d, oper_bw=%d, oper_ch_offet=%d\n",
  239. rtw_get_oper_ch(padapter), rtw_get_oper_bw(padapter), rtw_get_oper_choffset(padapter));
  240. *eof = 1;
  241. return len;
  242. }
  243. int proc_get_ap_info(char *page, char **start,
  244. off_t offset, int count,
  245. int *eof, void *data)
  246. {
  247. struct sta_info *psta;
  248. struct net_device *dev = data;
  249. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  250. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  251. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  252. struct wlan_network *cur_network = &(pmlmepriv->cur_network);
  253. struct sta_priv *pstapriv = &padapter->stapriv;
  254. int len = 0;
  255. psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
  256. if(psta)
  257. {
  258. int i;
  259. struct recv_reorder_ctrl *preorder_ctrl;
  260. len += snprintf(page + len, count - len, "SSID=%s\n", cur_network->network.Ssid.Ssid);
  261. len += snprintf(page + len, count - len, "sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
  262. len += snprintf(page + len, count - len, "cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
  263. len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self);
  264. len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
  265. #ifdef CONFIG_80211N_HT
  266. len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
  267. len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi);
  268. len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
  269. len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
  270. #endif //CONFIG_80211N_HT
  271. for(i=0;i<16;i++)
  272. {
  273. preorder_ctrl = &psta->recvreorder_ctrl[i];
  274. if(preorder_ctrl->enable)
  275. {
  276. len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq);
  277. }
  278. }
  279. }
  280. else
  281. {
  282. len += snprintf(page + len, count - len, "can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress));
  283. }
  284. *eof = 1;
  285. return len;
  286. }
  287. int proc_get_adapter_state(char *page, char **start,
  288. off_t offset, int count,
  289. int *eof, void *data)
  290. {
  291. struct net_device *dev = data;
  292. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  293. int len = 0;
  294. len += snprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n",
  295. padapter->bSurpriseRemoved, padapter->bDriverStopped);
  296. *eof = 1;
  297. return len;
  298. }
  299. int proc_get_trx_info(char *page, char **start,
  300. off_t offset, int count,
  301. int *eof, void *data)
  302. {
  303. int i;
  304. struct net_device *dev = data;
  305. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  306. struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
  307. struct recv_priv *precvpriv = &padapter->recvpriv;
  308. struct hw_xmit *phwxmit;
  309. int len = 0;
  310. len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d"
  311. ", free_ext_xmitbuf_cnt=%d, free_xframe_ext_cnt=%d"
  312. ", free_recvframe_cnt=%d\n",
  313. pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt,
  314. pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xframe_ext_cnt,
  315. precvpriv->free_recvframe_cnt);
  316. for(i = 0; i < 4; i++)
  317. {
  318. phwxmit = pxmitpriv->hwxmits + i;
  319. len += snprintf(page + len, count - len, "%d, hwq.accnt=%d\n", i, phwxmit->accnt);
  320. }
  321. #ifdef CONFIG_USB_HCI
  322. len += snprintf(page + len, count - len, "rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt);
  323. #endif
  324. *eof = 1;
  325. return len;
  326. }
  327. int proc_get_mac_reg_dump1(char *page, char **start,
  328. off_t offset, int count,
  329. int *eof, void *data)
  330. {
  331. struct net_device *dev = data;
  332. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  333. int len = 0;
  334. int i,j=1;
  335. len += snprintf(page + len, count - len, "\n======= MAC REG =======\n");
  336. for(i=0x0;i<0x300;i+=4)
  337. {
  338. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  339. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  340. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  341. }
  342. *eof = 1;
  343. return len;
  344. }
  345. int proc_get_mac_reg_dump2(char *page, char **start,
  346. off_t offset, int count,
  347. int *eof, void *data)
  348. {
  349. struct net_device *dev = data;
  350. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  351. int len = 0;
  352. int i,j=1;
  353. len += snprintf(page + len, count - len, "\n======= MAC REG =======\n");
  354. memset(page, 0, count);
  355. for(i=0x300;i<0x600;i+=4)
  356. {
  357. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  358. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  359. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  360. }
  361. *eof = 1;
  362. return len;
  363. }
  364. int proc_get_mac_reg_dump3(char *page, char **start,
  365. off_t offset, int count,
  366. int *eof, void *data)
  367. {
  368. struct net_device *dev = data;
  369. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  370. int len = 0;
  371. int i,j=1;
  372. len += snprintf(page + len, count - len, "\n======= MAC REG =======\n");
  373. for(i=0x600;i<0x800;i+=4)
  374. {
  375. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  376. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  377. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  378. }
  379. *eof = 1;
  380. return len;
  381. }
  382. int proc_get_bb_reg_dump1(char *page, char **start,
  383. off_t offset, int count,
  384. int *eof, void *data)
  385. {
  386. struct net_device *dev = data;
  387. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  388. int len = 0;
  389. int i,j=1;
  390. len += snprintf(page + len, count - len, "\n======= BB REG =======\n");
  391. for(i=0x800;i<0xB00;i+=4)
  392. {
  393. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  394. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  395. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  396. }
  397. *eof = 1;
  398. return len;
  399. }
  400. int proc_get_bb_reg_dump2(char *page, char **start,
  401. off_t offset, int count,
  402. int *eof, void *data)
  403. {
  404. struct net_device *dev = data;
  405. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  406. int len = 0;
  407. int i,j=1;
  408. len += snprintf(page + len, count - len, "\n======= BB REG =======\n");
  409. for(i=0xB00;i<0xE00;i+=4)
  410. {
  411. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  412. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  413. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  414. }
  415. *eof = 1;
  416. return len;
  417. }
  418. int proc_get_bb_reg_dump3(char *page, char **start,
  419. off_t offset, int count,
  420. int *eof, void *data)
  421. {
  422. struct net_device *dev = data;
  423. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  424. int len = 0;
  425. int i,j=1;
  426. len += snprintf(page + len, count - len, "\n======= BB REG =======\n");
  427. for(i=0xE00;i<0x1000;i+=4)
  428. {
  429. if(j%4==1) len += snprintf(page + len, count - len,"0x%02x",i);
  430. len += snprintf(page + len, count - len," 0x%08x ",rtw_read32(padapter,i));
  431. if((j++)%4 == 0) len += snprintf(page + len, count - len,"\n");
  432. }
  433. *eof = 1;
  434. return len;
  435. }
  436. int proc_get_rf_reg_dump1(char *page, char **start,
  437. off_t offset, int count,
  438. int *eof, void *data)
  439. {
  440. struct net_device *dev = data;
  441. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  442. int len = 0;
  443. int i,j=1,path;
  444. u32 value;
  445. len += snprintf(page + len, count - len, "\n======= RF REG =======\n");
  446. path = 1;
  447. len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path);
  448. for(i=0;i<0xC0;i++)
  449. {
  450. //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord);
  451. value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff);
  452. if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i);
  453. len += snprintf(page + len, count - len, " 0x%08x ",value);
  454. if((j++)%4==0) len += snprintf(page + len, count - len, "\n");
  455. }
  456. *eof = 1;
  457. return len;
  458. }
  459. int proc_get_rf_reg_dump2(char *page, char **start,
  460. off_t offset, int count,
  461. int *eof, void *data)
  462. {
  463. struct net_device *dev = data;
  464. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  465. int len = 0;
  466. int i,j=1,path;
  467. u32 value;
  468. len += snprintf(page + len, count - len, "\n======= RF REG =======\n");
  469. path = 1;
  470. len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path);
  471. for(i=0xC0;i<0x100;i++)
  472. {
  473. //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord);
  474. value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff);
  475. if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i);
  476. len += snprintf(page + len, count - len, " 0x%08x ",value);
  477. if((j++)%4==0) len += snprintf(page + len, count - len, "\n");
  478. }
  479. *eof = 1;
  480. return len;
  481. }
  482. int proc_get_rf_reg_dump3(char *page, char **start,
  483. off_t offset, int count,
  484. int *eof, void *data)
  485. {
  486. struct net_device *dev = data;
  487. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  488. int len = 0;
  489. int i,j=1,path;
  490. u32 value;
  491. len += snprintf(page + len, count - len, "\n======= RF REG =======\n");
  492. path = 2;
  493. len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path);
  494. for(i=0;i<0xC0;i++)
  495. {
  496. //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord);
  497. value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff);
  498. if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i);
  499. len += snprintf(page + len, count - len, " 0x%08x ",value);
  500. if((j++)%4==0) len += snprintf(page + len, count - len, "\n");
  501. }
  502. *eof = 1;
  503. return len;
  504. }
  505. int proc_get_rf_reg_dump4(char *page, char **start,
  506. off_t offset, int count,
  507. int *eof, void *data)
  508. {
  509. struct net_device *dev = data;
  510. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  511. int len = 0;
  512. int i,j=1,path;
  513. u32 value;
  514. len += snprintf(page + len, count - len, "\n======= RF REG =======\n");
  515. path = 2;
  516. len += snprintf(page + len, count - len, "\nRF_Path(%x)\n",path);
  517. for(i=0xC0;i<0x100;i++)
  518. {
  519. //value = PHY_QueryRFReg(padapter, (RF90_RADIO_PATH_E)path,i, bMaskDWord);
  520. value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff);
  521. if(j%4==1) len += snprintf(page + len, count - len, "0x%02x ",i);
  522. len += snprintf(page + len, count - len, " 0x%08x ",value);
  523. if((j++)%4==0) len += snprintf(page + len, count - len, "\n");
  524. }
  525. *eof = 1;
  526. return len;
  527. }
  528. int proc_get_rx_signal(char *page, char **start,
  529. off_t offset, int count,
  530. int *eof, void *data)
  531. {
  532. struct net_device *dev = data;
  533. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  534. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  535. int len = 0;
  536. len += snprintf(page + len, count - len,
  537. "rssi:%d\n"
  538. "rxpwdb:%d\n"
  539. "signal_strength:%u\n"
  540. "signal_qual:%u\n"
  541. "noise:%u\n",
  542. padapter->recvpriv.rssi,
  543. padapter->recvpriv.rxpwdb,
  544. padapter->recvpriv.signal_strength,
  545. padapter->recvpriv.signal_qual,
  546. padapter->recvpriv.noise
  547. );
  548. *eof = 1;
  549. return len;
  550. }
  551. int proc_set_rx_signal(struct file *file, const char *buffer,
  552. unsigned long count, void *data)
  553. {
  554. struct net_device *dev = (struct net_device *)data;
  555. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  556. char tmp[32];
  557. u32 is_signal_dbg, signal_strength;
  558. if (count < 1)
  559. return -EFAULT;
  560. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  561. int num = sscanf(tmp, "%u %u", &is_signal_dbg, &signal_strength);
  562. is_signal_dbg = is_signal_dbg==0?0:1;
  563. if(is_signal_dbg && num!=2)
  564. return count;
  565. signal_strength = signal_strength>100?100:signal_strength;
  566. signal_strength = signal_strength<0?0:signal_strength;
  567. padapter->recvpriv.is_signal_dbg = is_signal_dbg;
  568. padapter->recvpriv.signal_strength_dbg=signal_strength;
  569. if(is_signal_dbg)
  570. DBG_871X("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength);
  571. else
  572. DBG_871X("set %s\n", "HW_SIGNAL_STRENGTH");
  573. }
  574. return count;
  575. }
  576. #ifdef CONFIG_80211N_HT
  577. int proc_get_ht_enable(char *page, char **start,
  578. off_t offset, int count,
  579. int *eof, void *data)
  580. {
  581. struct net_device *dev = data;
  582. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  583. struct registry_priv *pregpriv = &padapter->registrypriv;
  584. int len = 0;
  585. if(pregpriv)
  586. len += snprintf(page + len, count - len,
  587. "%d\n",
  588. pregpriv->ht_enable
  589. );
  590. *eof = 1;
  591. return len;
  592. }
  593. int proc_set_ht_enable(struct file *file, const char *buffer,
  594. unsigned long count, void *data)
  595. {
  596. struct net_device *dev = (struct net_device *)data;
  597. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  598. struct registry_priv *pregpriv = &padapter->registrypriv;
  599. char tmp[32];
  600. u32 mode;
  601. if (count < 1)
  602. return -EFAULT;
  603. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  604. int num = sscanf(tmp, "%d ", &mode);
  605. if( pregpriv && mode >= 0 && mode < 2 )
  606. {
  607. pregpriv->ht_enable= mode;
  608. printk("ht_enable=%d\n", pregpriv->ht_enable);
  609. }
  610. }
  611. return count;
  612. }
  613. int proc_get_bw_mode(char *page, char **start,
  614. off_t offset, int count,
  615. int *eof, void *data)
  616. {
  617. struct net_device *dev = data;
  618. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  619. struct registry_priv *pregpriv = &padapter->registrypriv;
  620. int len = 0;
  621. if(pregpriv)
  622. len += snprintf(page + len, count - len,
  623. "%d\n",
  624. pregpriv->bw_mode
  625. );
  626. *eof = 1;
  627. return len;
  628. }
  629. int proc_set_bw_mode(struct file *file, const char *buffer,
  630. unsigned long count, void *data)
  631. {
  632. struct net_device *dev = (struct net_device *)data;
  633. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  634. struct registry_priv *pregpriv = &padapter->registrypriv;
  635. char tmp[32];
  636. u32 mode;
  637. if (count < 1)
  638. return -EFAULT;
  639. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  640. int num = sscanf(tmp, "%d ", &mode);
  641. if( pregpriv && mode >= 0 && mode < 2 )
  642. {
  643. pregpriv->bw_mode = mode;
  644. printk("bw_mode=%d\n", mode);
  645. }
  646. }
  647. return count;
  648. }
  649. int proc_get_ampdu_enable(char *page, char **start,
  650. off_t offset, int count,
  651. int *eof, void *data)
  652. {
  653. struct net_device *dev = data;
  654. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  655. struct registry_priv *pregpriv = &padapter->registrypriv;
  656. int len = 0;
  657. if(pregpriv)
  658. len += snprintf(page + len, count - len,
  659. "%d\n",
  660. pregpriv->ampdu_enable
  661. );
  662. *eof = 1;
  663. return len;
  664. }
  665. int proc_set_ampdu_enable(struct file *file, const char *buffer,
  666. unsigned long count, void *data)
  667. {
  668. struct net_device *dev = (struct net_device *)data;
  669. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  670. struct registry_priv *pregpriv = &padapter->registrypriv;
  671. char tmp[32];
  672. u32 mode;
  673. if (count < 1)
  674. return -EFAULT;
  675. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  676. int num = sscanf(tmp, "%d ", &mode);
  677. if( pregpriv && mode >= 0 && mode < 3 )
  678. {
  679. pregpriv->ampdu_enable= mode;
  680. printk("ampdu_enable=%d\n", mode);
  681. }
  682. }
  683. return count;
  684. }
  685. #endif //CONFIG_80211N_HT
  686. int proc_get_two_path_rssi(char *page, char **start,
  687. off_t offset, int count,
  688. int *eof, void *data)
  689. {
  690. struct net_device *dev = data;
  691. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  692. int len = 0;
  693. if(padapter)
  694. len += snprintf(page + len, count - len,
  695. "%d %d\n",
  696. padapter->recvpriv.RxRssi[0],
  697. padapter->recvpriv.RxRssi[1]
  698. );
  699. *eof = 1;
  700. return len;
  701. }
  702. #ifdef CONFIG_80211N_HT
  703. int proc_get_rx_stbc(char *page, char **start,
  704. off_t offset, int count,
  705. int *eof, void *data)
  706. {
  707. struct net_device *dev = data;
  708. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  709. struct registry_priv *pregpriv = &padapter->registrypriv;
  710. int len = 0;
  711. if(pregpriv)
  712. len += snprintf(page + len, count - len,
  713. "%d\n",
  714. pregpriv->rx_stbc
  715. );
  716. *eof = 1;
  717. return len;
  718. }
  719. int proc_set_rx_stbc(struct file *file, const char *buffer,
  720. unsigned long count, void *data)
  721. {
  722. struct net_device *dev = (struct net_device *)data;
  723. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  724. struct registry_priv *pregpriv = &padapter->registrypriv;
  725. char tmp[32];
  726. u32 mode;
  727. if (count < 1)
  728. return -EFAULT;
  729. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  730. int num = sscanf(tmp, "%d ", &mode);
  731. if( pregpriv && (mode == 0 || mode == 1|| mode == 2|| mode == 3))
  732. {
  733. pregpriv->rx_stbc= mode;
  734. printk("rx_stbc=%d\n", mode);
  735. }
  736. }
  737. return count;
  738. }
  739. #endif //CONFIG_80211N_HT
  740. int proc_get_rssi_disp(char *page, char **start,
  741. off_t offset, int count,
  742. int *eof, void *data)
  743. {
  744. *eof = 1;
  745. return 0;
  746. }
  747. int proc_set_rssi_disp(struct file *file, const char *buffer,
  748. unsigned long count, void *data)
  749. {
  750. struct net_device *dev = (struct net_device *)data;
  751. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  752. char tmp[32];
  753. u32 enable=0;
  754. if (count < 1)
  755. {
  756. DBG_8192C("argument size is less than 1\n");
  757. return -EFAULT;
  758. }
  759. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  760. int num = sscanf(tmp, "%x", &enable);
  761. if (num != 1) {
  762. DBG_8192C("invalid set_rssi_disp parameter!\n");
  763. return count;
  764. }
  765. if(enable)
  766. {
  767. DBG_8192C("Linked info Function Enable\n");
  768. padapter->bLinkInfoDump = enable ;
  769. }
  770. else
  771. {
  772. DBG_8192C("Linked info Function Disable\n");
  773. padapter->bLinkInfoDump = 0 ;
  774. }
  775. }
  776. return count;
  777. }
  778. #ifdef CONFIG_AP_MODE
  779. int proc_get_all_sta_info(char *page, char **start,
  780. off_t offset, int count,
  781. int *eof, void *data)
  782. {
  783. _irqL irqL;
  784. struct sta_info *psta;
  785. struct net_device *dev = data;
  786. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  787. struct sta_priv *pstapriv = &padapter->stapriv;
  788. int i, j;
  789. _list *plist, *phead;
  790. struct recv_reorder_ctrl *preorder_ctrl;
  791. int len = 0;
  792. len += snprintf(page + len, count - len, "sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap);
  793. _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
  794. for(i=0; i< NUM_STA; i++)
  795. {
  796. phead = &(pstapriv->sta_hash[i]);
  797. plist = get_next(phead);
  798. while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
  799. {
  800. psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
  801. plist = get_next(plist);
  802. //if(extra_arg == psta->aid)
  803. {
  804. len += snprintf(page + len, count - len, "sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
  805. len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self);
  806. len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
  807. #ifdef CONFIG_80211N_HT
  808. len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
  809. len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi);
  810. len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
  811. len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
  812. #endif //CONFIG_80211N_HT
  813. len += snprintf(page + len, count - len, "sleepq_len=%d\n", psta->sleepq_len);
  814. len += snprintf(page + len, count - len, "capability=0x%x\n", psta->capability);
  815. len += snprintf(page + len, count - len, "flags=0x%x\n", psta->flags);
  816. len += snprintf(page + len, count - len, "wpa_psk=0x%x\n", psta->wpa_psk);
  817. len += snprintf(page + len, count - len, "wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher);
  818. len += snprintf(page + len, count - len, "wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher);
  819. len += snprintf(page + len, count - len, "qos_info=0x%x\n", psta->qos_info);
  820. len += snprintf(page + len, count - len, "dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy);
  821. for(j=0;j<16;j++)
  822. {
  823. preorder_ctrl = &psta->recvreorder_ctrl[j];
  824. if(preorder_ctrl->enable)
  825. {
  826. len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq);
  827. }
  828. }
  829. }
  830. }
  831. }
  832. _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
  833. *eof = 1;
  834. return len;
  835. }
  836. #endif
  837. #ifdef DBG_MEMORY_LEAK
  838. #include <asm/atomic.h>
  839. extern atomic_t _malloc_cnt;;
  840. extern atomic_t _malloc_size;;
  841. int proc_get_malloc_cnt(char *page, char **start,
  842. off_t offset, int count,
  843. int *eof, void *data)
  844. {
  845. int len = 0;
  846. len += snprintf(page + len, count - len, "_malloc_cnt=%d\n", atomic_read(&_malloc_cnt));
  847. len += snprintf(page + len, count - len, "_malloc_size=%d\n", atomic_read(&_malloc_size));
  848. *eof = 1;
  849. return len;
  850. }
  851. #endif /* DBG_MEMORY_LEAK */
  852. #ifdef CONFIG_FIND_BEST_CHANNEL
  853. int proc_get_best_channel(char *page, char **start,
  854. off_t offset, int count,
  855. int *eof, void *data)
  856. {
  857. struct net_device *dev = data;
  858. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  859. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  860. int len = 0;
  861. u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, index_5G = 0;
  862. for (i=0; pmlmeext->channel_set[i].ChannelNum !=0; i++) {
  863. if ( pmlmeext->channel_set[i].ChannelNum == 1)
  864. index_24G = i;
  865. if ( pmlmeext->channel_set[i].ChannelNum == 36)
  866. index_5G = i;
  867. }
  868. for (i=0; pmlmeext->channel_set[i].ChannelNum !=0; i++) {
  869. // 2.4G
  870. if ( pmlmeext->channel_set[i].ChannelNum == 6 ) {
  871. if ( pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_24G].rx_count ) {
  872. index_24G = i;
  873. best_channel_24G = pmlmeext->channel_set[i].ChannelNum;
  874. }
  875. }
  876. // 5G
  877. if ( pmlmeext->channel_set[i].ChannelNum >= 36
  878. && pmlmeext->channel_set[i].ChannelNum < 140 ) {
  879. // Find primary channel
  880. if ( (( pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 0)
  881. && (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count) ) {
  882. index_5G = i;
  883. best_channel_5G = pmlmeext->channel_set[i].ChannelNum;
  884. }
  885. }
  886. if ( pmlmeext->channel_set[i].ChannelNum >= 149
  887. && pmlmeext->channel_set[i].ChannelNum < 165) {
  888. // find primary channel
  889. if ( (( pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 0)
  890. && (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count) ) {
  891. index_5G = i;
  892. best_channel_5G = pmlmeext->channel_set[i].ChannelNum;
  893. }
  894. }
  895. #if 1 // debug
  896. len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n",
  897. pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count);
  898. #endif
  899. }
  900. len += snprintf(page + len, count - len, "best_channel_5G = %d\n", best_channel_5G);
  901. len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G);
  902. *eof = 1;
  903. return len;
  904. }
  905. #endif /* CONFIG_FIND_BEST_CHANNEL */
  906. #ifdef CONFIG_BT_COEXIST
  907. #define _bt_dbg_off_ 0
  908. #define _bt_dbg_on_ 1
  909. extern u32 BTCoexDbgLevel;
  910. int proc_get_btcoex_dbg(char *page, char **start,
  911. off_t offset, int count,
  912. int *eof, void *data)
  913. {
  914. struct net_device *dev = data;
  915. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  916. struct registry_priv *pregpriv = &padapter->registrypriv;
  917. int len = 0;
  918. if(pregpriv)
  919. len += snprintf(page + len, count - len,
  920. "%d\n",
  921. BTCoexDbgLevel
  922. );
  923. *eof = 1;
  924. return len;
  925. }
  926. int proc_set_btcoex_dbg(struct file *file, const char *buffer,
  927. unsigned long count, void *data)
  928. {
  929. struct net_device *dev = (struct net_device *)data;
  930. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  931. struct registry_priv *pregpriv = &padapter->registrypriv;
  932. char tmp[32];
  933. u32 mode;
  934. if (count < 1)
  935. return -EFAULT;
  936. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  937. int num = sscanf(tmp, "%d ", &mode);
  938. if( pregpriv && (mode == 0 || mode == 1|| mode == 2|| mode == 3))
  939. {
  940. BTCoexDbgLevel= mode;
  941. printk("btcoex_dbg=%d\n", BTCoexDbgLevel);
  942. }
  943. }
  944. return count;
  945. }
  946. #endif /* CONFIG_BT_COEXIST */
  947. #if defined(DBG_CONFIG_ERROR_DETECT)
  948. int proc_get_sreset(char *page, char **start, off_t offset, int count, int *eof, void *data)
  949. {
  950. struct net_device *dev = data;
  951. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  952. struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
  953. int len = 0;
  954. *eof = 1;
  955. return len;
  956. }
  957. int proc_set_sreset(struct file *file, const char *buffer, unsigned long count, void *data)
  958. {
  959. struct net_device *dev = (struct net_device *)data;
  960. _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
  961. char tmp[32];
  962. s32 trigger_point;
  963. if (count < 1)
  964. return -EFAULT;
  965. if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
  966. int num = sscanf(tmp, "%d", &trigger_point);
  967. if (trigger_point == SRESET_TGP_NULL)
  968. rtw_hal_sreset_reset(padapter);
  969. else
  970. sreset_set_trigger_point(padapter, trigger_point);
  971. }
  972. return count;
  973. }
  974. #endif /* DBG_CONFIG_ERROR_DETECT */
  975. #endif