1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
3 *
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 *
6 ******************************************************************************/
7 #define _RTW_DEBUG_C_
8
9 #include <drv_types.h>
10 #include <rtw_debug.h>
11
12 u32 GlobalDebugLevel = _drv_err_;
13
14 #ifdef DEBUG_RTL871X
15
16 u64 GlobalDebugComponents = \
17 _module_rtl871x_xmit_c_ |
18 _module_xmit_osdep_c_ |
19 _module_rtl871x_recv_c_ |
20 _module_recv_osdep_c_ |
21 _module_rtl871x_mlme_c_ |
22 _module_mlme_osdep_c_ |
23 _module_rtl871x_sta_mgt_c_ |
24 _module_rtl871x_cmd_c_ |
25 _module_cmd_osdep_c_ |
26 _module_rtl871x_io_c_ |
27 _module_io_osdep_c_ |
28 _module_os_intfs_c_|
29 _module_rtl871x_security_c_|
30 _module_rtl871x_eeprom_c_|
31 _module_hal_init_c_|
32 _module_hci_hal_init_c_|
33 _module_rtl871x_ioctl_c_|
34 _module_rtl871x_ioctl_set_c_|
35 _module_rtl871x_ioctl_query_c_|
36 _module_rtl871x_pwrctrl_c_|
37 _module_hci_intfs_c_|
38 _module_hci_ops_c_|
39 _module_hci_ops_os_c_|
40 _module_rtl871x_ioctl_os_c|
41 _module_rtl8712_cmd_c_|
42 _module_hal_xmit_c_|
43 _module_rtl8712_recv_c_ |
44 _module_mp_ |
45 _module_efuse_;
46
47 #endif /* DEBUG_RTL871X */
48
49 #include <rtw_version.h>
50
dump_drv_version(void * sel)51 void dump_drv_version(void *sel)
52 {
53 DBG_871X_SEL_NL(sel, "%s %s\n", "rtl8723bs", DRIVERVERSION);
54 }
55
dump_log_level(void * sel)56 void dump_log_level(void *sel)
57 {
58 DBG_871X_SEL_NL(sel, "log_level:%d\n", GlobalDebugLevel);
59 }
60
sd_f0_reg_dump(void * sel,struct adapter * adapter)61 void sd_f0_reg_dump(void *sel, struct adapter *adapter)
62 {
63 int i;
64
65 for (i = 0x0; i <= 0xff; i++) {
66 if (i%16 == 0)
67 DBG_871X_SEL_NL(sel, "0x%02x ", i);
68
69 DBG_871X_SEL(sel, "%02x ", rtw_sd_f0_read8(adapter, i));
70
71 if (i%16 == 15)
72 DBG_871X_SEL(sel, "\n");
73 else if (i%8 == 7)
74 DBG_871X_SEL(sel, "\t");
75 }
76 }
77
mac_reg_dump(void * sel,struct adapter * adapter)78 void mac_reg_dump(void *sel, struct adapter *adapter)
79 {
80 int i, j = 1;
81
82 DBG_871X_SEL_NL(sel, "======= MAC REG =======\n");
83
84 for (i = 0x0; i < 0x800; i += 4) {
85 if (j%4 == 1)
86 DBG_871X_SEL_NL(sel, "0x%03x", i);
87 DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i));
88 if ((j++)%4 == 0)
89 DBG_871X_SEL(sel, "\n");
90 }
91 }
92
bb_reg_dump(void * sel,struct adapter * adapter)93 void bb_reg_dump(void *sel, struct adapter *adapter)
94 {
95 int i, j = 1;
96
97 DBG_871X_SEL_NL(sel, "======= BB REG =======\n");
98 for (i = 0x800; i < 0x1000 ; i += 4) {
99 if (j%4 == 1)
100 DBG_871X_SEL_NL(sel, "0x%03x", i);
101 DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i));
102 if ((j++)%4 == 0)
103 DBG_871X_SEL(sel, "\n");
104 }
105 }
106
rf_reg_dump(void * sel,struct adapter * adapter)107 void rf_reg_dump(void *sel, struct adapter *adapter)
108 {
109 int i, j = 1, path;
110 u32 value;
111 u8 rf_type = 0;
112 u8 path_nums = 0;
113
114 rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
115 if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type))
116 path_nums = 1;
117 else
118 path_nums = 2;
119
120 DBG_871X_SEL_NL(sel, "======= RF REG =======\n");
121
122 for (path = 0; path < path_nums; path++) {
123 DBG_871X_SEL_NL(sel, "RF_Path(%x)\n", path);
124 for (i = 0; i < 0x100; i++) {
125 value = rtw_hal_read_rfreg(adapter, path, i, 0xffffffff);
126 if (j%4 == 1)
127 DBG_871X_SEL_NL(sel, "0x%02x ", i);
128 DBG_871X_SEL(sel, " 0x%08x ", value);
129 if ((j++)%4 == 0)
130 DBG_871X_SEL(sel, "\n");
131 }
132 }
133 }
134
135 #ifdef PROC_DEBUG
proc_set_write_reg(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)136 ssize_t proc_set_write_reg(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
137 {
138 struct net_device *dev = data;
139 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
140 char tmp[32];
141 u32 addr, val, len;
142
143 if (count < 3) {
144 DBG_871X("argument size is less than 3\n");
145 return -EFAULT;
146 }
147
148 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
149
150 int num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
151
152 if (num != 3) {
153 DBG_871X("invalid write_reg parameter!\n");
154 return count;
155 }
156
157 switch (len) {
158 case 1:
159 rtw_write8(padapter, addr, (u8)val);
160 break;
161 case 2:
162 rtw_write16(padapter, addr, (u16)val);
163 break;
164 case 4:
165 rtw_write32(padapter, addr, val);
166 break;
167 default:
168 DBG_871X("error write length =%d", len);
169 break;
170 }
171
172 }
173
174 return count;
175
176 }
177
178 static u32 proc_get_read_addr = 0xeeeeeeee;
179 static u32 proc_get_read_len = 0x4;
180
proc_get_read_reg(struct seq_file * m,void * v)181 int proc_get_read_reg(struct seq_file *m, void *v)
182 {
183 struct net_device *dev = m->private;
184 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
185
186 if (proc_get_read_addr == 0xeeeeeeee) {
187 DBG_871X_SEL_NL(m, "address not initialized\n");
188 return 0;
189 }
190
191 switch (proc_get_read_len) {
192 case 1:
193 DBG_871X_SEL_NL(m, "rtw_read8(0x%x) = 0x%x\n", proc_get_read_addr, rtw_read8(padapter, proc_get_read_addr));
194 break;
195 case 2:
196 DBG_871X_SEL_NL(m, "rtw_read16(0x%x) = 0x%x\n", proc_get_read_addr, rtw_read16(padapter, proc_get_read_addr));
197 break;
198 case 4:
199 DBG_871X_SEL_NL(m, "rtw_read32(0x%x) = 0x%x\n", proc_get_read_addr, rtw_read32(padapter, proc_get_read_addr));
200 break;
201 default:
202 DBG_871X_SEL_NL(m, "error read length =%d\n", proc_get_read_len);
203 break;
204 }
205
206 return 0;
207 }
208
proc_set_read_reg(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)209 ssize_t proc_set_read_reg(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
210 {
211 char tmp[16];
212 u32 addr, len;
213
214 if (count < 2) {
215 DBG_871X("argument size is less than 2\n");
216 return -EFAULT;
217 }
218
219 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
220
221 int num = sscanf(tmp, "%x %x", &addr, &len);
222
223 if (num != 2) {
224 DBG_871X("invalid read_reg parameter!\n");
225 return count;
226 }
227
228 proc_get_read_addr = addr;
229
230 proc_get_read_len = len;
231 }
232
233 return count;
234
235 }
236
proc_get_fwstate(struct seq_file * m,void * v)237 int proc_get_fwstate(struct seq_file *m, void *v)
238 {
239 struct net_device *dev = m->private;
240 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
241 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
242
243 DBG_871X_SEL_NL(m, "fwstate = 0x%x\n", get_fwstate(pmlmepriv));
244
245 return 0;
246 }
247
proc_get_sec_info(struct seq_file * m,void * v)248 int proc_get_sec_info(struct seq_file *m, void *v)
249 {
250 struct net_device *dev = m->private;
251 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
252 struct security_priv *sec = &padapter->securitypriv;
253
254 DBG_871X_SEL_NL(m, "auth_alg = 0x%x, enc_alg = 0x%x, auth_type = 0x%x, enc_type = 0x%x\n",
255 sec->dot11AuthAlgrthm, sec->dot11PrivacyAlgrthm,
256 sec->ndisauthtype, sec->ndisencryptstatus);
257
258 DBG_871X_SEL_NL(m, "hw_decrypted =%d\n", sec->hw_decrypted);
259
260 #ifdef DBG_SW_SEC_CNT
261 DBG_871X_SEL_NL(m, "wep_sw_enc_cnt =%llu, %llu, %llu\n"
262 , sec->wep_sw_enc_cnt_bc, sec->wep_sw_enc_cnt_mc, sec->wep_sw_enc_cnt_uc);
263 DBG_871X_SEL_NL(m, "wep_sw_dec_cnt =%llu, %llu, %llu\n"
264 , sec->wep_sw_dec_cnt_bc, sec->wep_sw_dec_cnt_mc, sec->wep_sw_dec_cnt_uc);
265
266 DBG_871X_SEL_NL(m, "tkip_sw_enc_cnt =%llu, %llu, %llu\n"
267 , sec->tkip_sw_enc_cnt_bc, sec->tkip_sw_enc_cnt_mc, sec->tkip_sw_enc_cnt_uc);
268 DBG_871X_SEL_NL(m, "tkip_sw_dec_cnt =%llu, %llu, %llu\n"
269 , sec->tkip_sw_dec_cnt_bc, sec->tkip_sw_dec_cnt_mc, sec->tkip_sw_dec_cnt_uc);
270
271 DBG_871X_SEL_NL(m, "aes_sw_enc_cnt =%llu, %llu, %llu\n"
272 , sec->aes_sw_enc_cnt_bc, sec->aes_sw_enc_cnt_mc, sec->aes_sw_enc_cnt_uc);
273 DBG_871X_SEL_NL(m, "aes_sw_dec_cnt =%llu, %llu, %llu\n"
274 , sec->aes_sw_dec_cnt_bc, sec->aes_sw_dec_cnt_mc, sec->aes_sw_dec_cnt_uc);
275 #endif /* DBG_SW_SEC_CNT */
276
277 return 0;
278 }
279
proc_get_mlmext_state(struct seq_file * m,void * v)280 int proc_get_mlmext_state(struct seq_file *m, void *v)
281 {
282 struct net_device *dev = m->private;
283 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
284 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
285 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
286
287 DBG_871X_SEL_NL(m, "pmlmeinfo->state = 0x%x\n", pmlmeinfo->state);
288
289 return 0;
290 }
291
proc_get_roam_flags(struct seq_file * m,void * v)292 int proc_get_roam_flags(struct seq_file *m, void *v)
293 {
294 struct net_device *dev = m->private;
295 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
296
297 DBG_871X_SEL_NL(m, "0x%02x\n", rtw_roam_flags(adapter));
298
299 return 0;
300 }
301
proc_set_roam_flags(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)302 ssize_t proc_set_roam_flags(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
303 {
304 struct net_device *dev = data;
305 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
306
307 char tmp[32];
308 u8 flags;
309
310 if (count < 1)
311 return -EFAULT;
312
313 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
314
315 int num = sscanf(tmp, "%hhx", &flags);
316
317 if (num == 1)
318 rtw_assign_roam_flags(adapter, flags);
319 }
320
321 return count;
322
323 }
324
proc_get_roam_param(struct seq_file * m,void * v)325 int proc_get_roam_param(struct seq_file *m, void *v)
326 {
327 struct net_device *dev = m->private;
328 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
329 struct mlme_priv *mlme = &adapter->mlmepriv;
330
331 DBG_871X_SEL_NL(m, "%12s %12s %11s\n", "rssi_diff_th", "scanr_exp_ms", "scan_int_ms");
332 DBG_871X_SEL_NL(m, "%-12u %-12u %-11u\n"
333 , mlme->roam_rssi_diff_th
334 , mlme->roam_scanr_exp_ms
335 , mlme->roam_scan_int_ms
336 );
337
338 return 0;
339 }
340
proc_set_roam_param(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)341 ssize_t proc_set_roam_param(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
342 {
343 struct net_device *dev = data;
344 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
345 struct mlme_priv *mlme = &adapter->mlmepriv;
346
347 char tmp[32];
348 u8 rssi_diff_th;
349 u32 scanr_exp_ms;
350 u32 scan_int_ms;
351
352 if (count < 1)
353 return -EFAULT;
354
355 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
356
357 int num = sscanf(tmp, "%hhu %u %u", &rssi_diff_th, &scanr_exp_ms, &scan_int_ms);
358
359 if (num >= 1)
360 mlme->roam_rssi_diff_th = rssi_diff_th;
361 if (num >= 2)
362 mlme->roam_scanr_exp_ms = scanr_exp_ms;
363 if (num >= 3)
364 mlme->roam_scan_int_ms = scan_int_ms;
365 }
366
367 return count;
368
369 }
370
proc_set_roam_tgt_addr(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)371 ssize_t proc_set_roam_tgt_addr(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
372 {
373 struct net_device *dev = data;
374 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
375
376 char tmp[32];
377 u8 addr[ETH_ALEN];
378
379 if (count < 1)
380 return -EFAULT;
381
382 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
383
384 int num = sscanf(tmp, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", addr, addr+1, addr+2, addr+3, addr+4, addr+5);
385 if (num == 6)
386 memcpy(adapter->mlmepriv.roam_tgt_addr, addr, ETH_ALEN);
387
388 DBG_871X("set roam_tgt_addr to "MAC_FMT"\n", MAC_ARG(adapter->mlmepriv.roam_tgt_addr));
389 }
390
391 return count;
392 }
393
proc_get_qos_option(struct seq_file * m,void * v)394 int proc_get_qos_option(struct seq_file *m, void *v)
395 {
396 struct net_device *dev = m->private;
397 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
398 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
399
400 DBG_871X_SEL_NL(m, "qos_option =%d\n", pmlmepriv->qospriv.qos_option);
401
402 return 0;
403 }
404
proc_get_ht_option(struct seq_file * m,void * v)405 int proc_get_ht_option(struct seq_file *m, void *v)
406 {
407 struct net_device *dev = m->private;
408 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
409 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
410
411 DBG_871X_SEL_NL(m, "ht_option =%d\n", pmlmepriv->htpriv.ht_option);
412
413 return 0;
414 }
415
proc_get_rf_info(struct seq_file * m,void * v)416 int proc_get_rf_info(struct seq_file *m, void *v)
417 {
418 struct net_device *dev = m->private;
419 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
420 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
421
422 DBG_871X_SEL_NL(m, "cur_ch =%d, cur_bw =%d, cur_ch_offet =%d\n",
423 pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
424
425 DBG_871X_SEL_NL(m, "oper_ch =%d, oper_bw =%d, oper_ch_offet =%d\n",
426 rtw_get_oper_ch(padapter), rtw_get_oper_bw(padapter), rtw_get_oper_choffset(padapter));
427
428 return 0;
429 }
430
proc_get_survey_info(struct seq_file * m,void * v)431 int proc_get_survey_info(struct seq_file *m, void *v)
432 {
433 struct net_device *dev = m->private;
434 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
435 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
436 struct __queue *queue = &(pmlmepriv->scanned_queue);
437 struct wlan_network *pnetwork = NULL;
438 struct list_head *plist, *phead;
439 s32 notify_signal;
440 s16 notify_noise = 0;
441 u16 index = 0;
442
443 spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
444 phead = get_list_head(queue);
445 plist = phead ? get_next(phead) : NULL;
446 if ((!phead) || (!plist)) {
447 spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
448 return 0;
449 }
450
451 DBG_871X_SEL_NL(m, "%5s %-17s %3s %-3s %-4s %-4s %5s %s\n", "index", "bssid", "ch", "RSSI", "SdBm", "Noise", "age", "ssid");
452 while (1) {
453 if (phead == plist)
454 break;
455
456 pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
457
458 if (!pnetwork)
459 break;
460
461 if (check_fwstate(pmlmepriv, _FW_LINKED) == true &&
462 is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) {
463 notify_signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);/*dbm*/
464 } else {
465 notify_signal = translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength);/*dbm*/
466 }
467
468 #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
469 rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(pnetwork->network.Configuration.DSConfig), &(notify_noise));
470 #endif
471
472 DBG_871X_SEL_NL(m, "%5d "MAC_FMT" %3d %3d %4d %4d %5d %s\n",
473 ++index,
474 MAC_ARG(pnetwork->network.MacAddress),
475 pnetwork->network.Configuration.DSConfig,
476 (int)pnetwork->network.Rssi,
477 notify_signal,
478 notify_noise,
479 jiffies_to_msecs(jiffies - pnetwork->last_scanned),
480 /*translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength),*/
481 pnetwork->network.Ssid.Ssid);
482 plist = get_next(plist);
483 }
484 spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
485
486 return 0;
487 }
488
proc_get_ap_info(struct seq_file * m,void * v)489 int proc_get_ap_info(struct seq_file *m, void *v)
490 {
491 struct net_device *dev = m->private;
492 struct sta_info *psta;
493 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
494 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
495 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
496 struct wlan_network *cur_network = &(pmlmepriv->cur_network);
497 struct sta_priv *pstapriv = &padapter->stapriv;
498
499 psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
500 if (psta) {
501 int i;
502 struct recv_reorder_ctrl *preorder_ctrl;
503
504 DBG_871X_SEL_NL(m, "SSID =%s\n", cur_network->network.Ssid.Ssid);
505 DBG_871X_SEL_NL(m, "sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
506 DBG_871X_SEL_NL(m, "cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
507 DBG_871X_SEL_NL(m, "wireless_mode = 0x%x, rtsen =%d, cts2slef =%d\n", psta->wireless_mode, psta->rtsen, psta->cts2self);
508 DBG_871X_SEL_NL(m, "state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
509 DBG_871X_SEL_NL(m, "qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
510 DBG_871X_SEL_NL(m, "bwmode =%d, ch_offset =%d, sgi_20m =%d, sgi_40m =%d\n", psta->bw_mode, psta->htpriv.ch_offset, psta->htpriv.sgi_20m, psta->htpriv.sgi_40m);
511 DBG_871X_SEL_NL(m, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
512 DBG_871X_SEL_NL(m, "agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
513 DBG_871X_SEL_NL(m, "ldpc_cap = 0x%x, stbc_cap = 0x%x, beamform_cap = 0x%x\n", psta->htpriv.ldpc_cap, psta->htpriv.stbc_cap, psta->htpriv.beamform_cap);
514
515 for (i = 0; i < 16; i++) {
516 preorder_ctrl = &psta->recvreorder_ctrl[i];
517 if (preorder_ctrl->enable) {
518 DBG_871X_SEL_NL(m, "tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq);
519 }
520 }
521
522 } else{
523 DBG_871X_SEL_NL(m, "can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress));
524 }
525
526 return 0;
527 }
528
proc_get_adapter_state(struct seq_file * m,void * v)529 int proc_get_adapter_state(struct seq_file *m, void *v)
530 {
531 struct net_device *dev = m->private;
532 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
533
534 DBG_871X_SEL_NL(m, "name =%s, bSurpriseRemoved =%d, bDriverStopped =%d\n",
535 dev->name, padapter->bSurpriseRemoved, padapter->bDriverStopped);
536
537 return 0;
538 }
539
proc_get_trx_info(struct seq_file * m,void * v)540 int proc_get_trx_info(struct seq_file *m, void *v)
541 {
542 struct net_device *dev = m->private;
543 int i;
544 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
545 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
546 struct recv_priv *precvpriv = &padapter->recvpriv;
547 struct hw_xmit *phwxmit;
548
549 DBG_871X_SEL_NL(m, "free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d\n"
550 , pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt);
551 DBG_871X_SEL_NL(m, "free_ext_xmitbuf_cnt =%d, free_xframe_ext_cnt =%d\n"
552 , pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xframe_ext_cnt);
553 DBG_871X_SEL_NL(m, "free_recvframe_cnt =%d\n"
554 , precvpriv->free_recvframe_cnt);
555
556 for (i = 0; i < 4; i++) {
557 phwxmit = pxmitpriv->hwxmits + i;
558 DBG_871X_SEL_NL(m, "%d, hwq.accnt =%d\n", i, phwxmit->accnt);
559 }
560
561 return 0;
562 }
563
proc_get_rate_ctl(struct seq_file * m,void * v)564 int proc_get_rate_ctl(struct seq_file *m, void *v)
565 {
566 struct net_device *dev = m->private;
567 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
568
569 if (adapter->fix_rate != 0xff) {
570 DBG_871X_SEL_NL(m, "FIX\n");
571 DBG_871X_SEL_NL(m, "0x%02x\n", adapter->fix_rate);
572 } else {
573 DBG_871X_SEL_NL(m, "RA\n");
574 }
575
576 return 0;
577 }
578
proc_set_rate_ctl(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)579 ssize_t proc_set_rate_ctl(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
580 {
581 struct net_device *dev = data;
582 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
583 char tmp[32];
584 u8 fix_rate;
585
586 if (count < 1)
587 return -EFAULT;
588
589 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
590
591 int num = sscanf(tmp, "%hhx", &fix_rate);
592
593 if (num >= 1)
594 adapter->fix_rate = fix_rate;
595 }
596
597 return count;
598 }
599
proc_set_fwdl_test_case(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)600 ssize_t proc_set_fwdl_test_case(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
601 {
602 char tmp[32];
603
604 if (count < 1)
605 return -EFAULT;
606
607 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
608 sscanf(tmp, "%hhu %hhu", &g_fwdl_chksum_fail, &g_fwdl_wintint_rdy_fail);
609 }
610
611 return count;
612 }
613
proc_set_wait_hiq_empty(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)614 ssize_t proc_set_wait_hiq_empty(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
615 {
616 char tmp[32];
617
618 if (count < 1)
619 return -EFAULT;
620
621 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
622 sscanf(tmp, "%u", &g_wait_hiq_empty);
623 }
624
625 return count;
626 }
627
proc_get_suspend_resume_info(struct seq_file * m,void * v)628 int proc_get_suspend_resume_info(struct seq_file *m, void *v)
629 {
630 struct net_device *dev = m->private;
631 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
632 struct dvobj_priv *dvobj = padapter->dvobj;
633 struct debug_priv *pdbgpriv = &dvobj->drv_dbg;
634
635 DBG_871X_SEL_NL(m, "dbg_sdio_alloc_irq_cnt =%d\n", pdbgpriv->dbg_sdio_alloc_irq_cnt);
636 DBG_871X_SEL_NL(m, "dbg_sdio_free_irq_cnt =%d\n", pdbgpriv->dbg_sdio_free_irq_cnt);
637 DBG_871X_SEL_NL(m, "dbg_sdio_alloc_irq_error_cnt =%d\n", pdbgpriv->dbg_sdio_alloc_irq_error_cnt);
638 DBG_871X_SEL_NL(m, "dbg_sdio_free_irq_error_cnt =%d\n", pdbgpriv->dbg_sdio_free_irq_error_cnt);
639 DBG_871X_SEL_NL(m, "dbg_sdio_init_error_cnt =%d\n", pdbgpriv->dbg_sdio_init_error_cnt);
640 DBG_871X_SEL_NL(m, "dbg_sdio_deinit_error_cnt =%d\n", pdbgpriv->dbg_sdio_deinit_error_cnt);
641 DBG_871X_SEL_NL(m, "dbg_suspend_error_cnt =%d\n", pdbgpriv->dbg_suspend_error_cnt);
642 DBG_871X_SEL_NL(m, "dbg_suspend_cnt =%d\n", pdbgpriv->dbg_suspend_cnt);
643 DBG_871X_SEL_NL(m, "dbg_resume_cnt =%d\n", pdbgpriv->dbg_resume_cnt);
644 DBG_871X_SEL_NL(m, "dbg_resume_error_cnt =%d\n", pdbgpriv->dbg_resume_error_cnt);
645 DBG_871X_SEL_NL(m, "dbg_deinit_fail_cnt =%d\n", pdbgpriv->dbg_deinit_fail_cnt);
646 DBG_871X_SEL_NL(m, "dbg_carddisable_cnt =%d\n", pdbgpriv->dbg_carddisable_cnt);
647 DBG_871X_SEL_NL(m, "dbg_ps_insuspend_cnt =%d\n", pdbgpriv->dbg_ps_insuspend_cnt);
648 DBG_871X_SEL_NL(m, "dbg_dev_unload_inIPS_cnt =%d\n", pdbgpriv->dbg_dev_unload_inIPS_cnt);
649 DBG_871X_SEL_NL(m, "dbg_scan_pwr_state_cnt =%d\n", pdbgpriv->dbg_scan_pwr_state_cnt);
650 DBG_871X_SEL_NL(m, "dbg_downloadfw_pwr_state_cnt =%d\n", pdbgpriv->dbg_downloadfw_pwr_state_cnt);
651 DBG_871X_SEL_NL(m, "dbg_carddisable_error_cnt =%d\n", pdbgpriv->dbg_carddisable_error_cnt);
652 DBG_871X_SEL_NL(m, "dbg_fw_read_ps_state_fail_cnt =%d\n", pdbgpriv->dbg_fw_read_ps_state_fail_cnt);
653 DBG_871X_SEL_NL(m, "dbg_leave_ips_fail_cnt =%d\n", pdbgpriv->dbg_leave_ips_fail_cnt);
654 DBG_871X_SEL_NL(m, "dbg_leave_lps_fail_cnt =%d\n", pdbgpriv->dbg_leave_lps_fail_cnt);
655 DBG_871X_SEL_NL(m, "dbg_h2c_leave32k_fail_cnt =%d\n", pdbgpriv->dbg_h2c_leave32k_fail_cnt);
656 DBG_871X_SEL_NL(m, "dbg_diswow_dload_fw_fail_cnt =%d\n", pdbgpriv->dbg_diswow_dload_fw_fail_cnt);
657 DBG_871X_SEL_NL(m, "dbg_enwow_dload_fw_fail_cnt =%d\n", pdbgpriv->dbg_enwow_dload_fw_fail_cnt);
658 DBG_871X_SEL_NL(m, "dbg_ips_drvopen_fail_cnt =%d\n", pdbgpriv->dbg_ips_drvopen_fail_cnt);
659 DBG_871X_SEL_NL(m, "dbg_poll_fail_cnt =%d\n", pdbgpriv->dbg_poll_fail_cnt);
660 DBG_871X_SEL_NL(m, "dbg_rpwm_toogle_cnt =%d\n", pdbgpriv->dbg_rpwm_toogle_cnt);
661 DBG_871X_SEL_NL(m, "dbg_rpwm_timeout_fail_cnt =%d\n", pdbgpriv->dbg_rpwm_timeout_fail_cnt);
662
663 return 0;
664 }
665
666 #ifdef CONFIG_DBG_COUNTER
667
proc_get_rx_logs(struct seq_file * m,void * v)668 int proc_get_rx_logs(struct seq_file *m, void *v)
669 {
670 struct net_device *dev = m->private;
671 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
672 struct rx_logs *rx_logs = &padapter->rx_logs;
673
674 DBG_871X_SEL_NL(m,
675 "intf_rx =%d\n"
676 "intf_rx_err_recvframe =%d\n"
677 "intf_rx_err_skb =%d\n"
678 "intf_rx_report =%d\n"
679 "core_rx =%d\n"
680 "core_rx_pre =%d\n"
681 "core_rx_pre_ver_err =%d\n"
682 "core_rx_pre_mgmt =%d\n"
683 "core_rx_pre_mgmt_err_80211w =%d\n"
684 "core_rx_pre_mgmt_err =%d\n"
685 "core_rx_pre_ctrl =%d\n"
686 "core_rx_pre_ctrl_err =%d\n"
687 "core_rx_pre_data =%d\n"
688 "core_rx_pre_data_wapi_seq_err =%d\n"
689 "core_rx_pre_data_wapi_key_err =%d\n"
690 "core_rx_pre_data_handled =%d\n"
691 "core_rx_pre_data_err =%d\n"
692 "core_rx_pre_data_unknown =%d\n"
693 "core_rx_pre_unknown =%d\n"
694 "core_rx_enqueue =%d\n"
695 "core_rx_dequeue =%d\n"
696 "core_rx_post =%d\n"
697 "core_rx_post_decrypt =%d\n"
698 "core_rx_post_decrypt_wep =%d\n"
699 "core_rx_post_decrypt_tkip =%d\n"
700 "core_rx_post_decrypt_aes =%d\n"
701 "core_rx_post_decrypt_wapi =%d\n"
702 "core_rx_post_decrypt_hw =%d\n"
703 "core_rx_post_decrypt_unknown =%d\n"
704 "core_rx_post_decrypt_err =%d\n"
705 "core_rx_post_defrag_err =%d\n"
706 "core_rx_post_portctrl_err =%d\n"
707 "core_rx_post_indicate =%d\n"
708 "core_rx_post_indicate_in_oder =%d\n"
709 "core_rx_post_indicate_reoder =%d\n"
710 "core_rx_post_indicate_err =%d\n"
711 "os_indicate =%d\n"
712 "os_indicate_ap_mcast =%d\n"
713 "os_indicate_ap_forward =%d\n"
714 "os_indicate_ap_self =%d\n"
715 "os_indicate_err =%d\n"
716 "os_netif_ok =%d\n"
717 "os_netif_err =%d\n",
718 rx_logs->intf_rx,
719 rx_logs->intf_rx_err_recvframe,
720 rx_logs->intf_rx_err_skb,
721 rx_logs->intf_rx_report,
722 rx_logs->core_rx,
723 rx_logs->core_rx_pre,
724 rx_logs->core_rx_pre_ver_err,
725 rx_logs->core_rx_pre_mgmt,
726 rx_logs->core_rx_pre_mgmt_err_80211w,
727 rx_logs->core_rx_pre_mgmt_err,
728 rx_logs->core_rx_pre_ctrl,
729 rx_logs->core_rx_pre_ctrl_err,
730 rx_logs->core_rx_pre_data,
731 rx_logs->core_rx_pre_data_wapi_seq_err,
732 rx_logs->core_rx_pre_data_wapi_key_err,
733 rx_logs->core_rx_pre_data_handled,
734 rx_logs->core_rx_pre_data_err,
735 rx_logs->core_rx_pre_data_unknown,
736 rx_logs->core_rx_pre_unknown,
737 rx_logs->core_rx_enqueue,
738 rx_logs->core_rx_dequeue,
739 rx_logs->core_rx_post,
740 rx_logs->core_rx_post_decrypt,
741 rx_logs->core_rx_post_decrypt_wep,
742 rx_logs->core_rx_post_decrypt_tkip,
743 rx_logs->core_rx_post_decrypt_aes,
744 rx_logs->core_rx_post_decrypt_wapi,
745 rx_logs->core_rx_post_decrypt_hw,
746 rx_logs->core_rx_post_decrypt_unknown,
747 rx_logs->core_rx_post_decrypt_err,
748 rx_logs->core_rx_post_defrag_err,
749 rx_logs->core_rx_post_portctrl_err,
750 rx_logs->core_rx_post_indicate,
751 rx_logs->core_rx_post_indicate_in_oder,
752 rx_logs->core_rx_post_indicate_reoder,
753 rx_logs->core_rx_post_indicate_err,
754 rx_logs->os_indicate,
755 rx_logs->os_indicate_ap_mcast,
756 rx_logs->os_indicate_ap_forward,
757 rx_logs->os_indicate_ap_self,
758 rx_logs->os_indicate_err,
759 rx_logs->os_netif_ok,
760 rx_logs->os_netif_err
761 );
762
763 return 0;
764 }
765
proc_get_tx_logs(struct seq_file * m,void * v)766 int proc_get_tx_logs(struct seq_file *m, void *v)
767 {
768 struct net_device *dev = m->private;
769 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
770 struct tx_logs *tx_logs = &padapter->tx_logs;
771
772 DBG_871X_SEL_NL(m,
773 "os_tx =%d\n"
774 "os_tx_err_up =%d\n"
775 "os_tx_err_xmit =%d\n"
776 "os_tx_m2u =%d\n"
777 "os_tx_m2u_ignore_fw_linked =%d\n"
778 "os_tx_m2u_ignore_self =%d\n"
779 "os_tx_m2u_entry =%d\n"
780 "os_tx_m2u_entry_err_xmit =%d\n"
781 "os_tx_m2u_entry_err_skb =%d\n"
782 "os_tx_m2u_stop =%d\n"
783 "core_tx =%d\n"
784 "core_tx_err_pxmitframe =%d\n"
785 "core_tx_err_brtx =%d\n"
786 "core_tx_upd_attrib =%d\n"
787 "core_tx_upd_attrib_adhoc =%d\n"
788 "core_tx_upd_attrib_sta =%d\n"
789 "core_tx_upd_attrib_ap =%d\n"
790 "core_tx_upd_attrib_unknown =%d\n"
791 "core_tx_upd_attrib_dhcp =%d\n"
792 "core_tx_upd_attrib_icmp =%d\n"
793 "core_tx_upd_attrib_active =%d\n"
794 "core_tx_upd_attrib_err_ucast_sta =%d\n"
795 "core_tx_upd_attrib_err_ucast_ap_link =%d\n"
796 "core_tx_upd_attrib_err_sta =%d\n"
797 "core_tx_upd_attrib_err_link =%d\n"
798 "core_tx_upd_attrib_err_sec =%d\n"
799 "core_tx_ap_enqueue_warn_fwstate =%d\n"
800 "core_tx_ap_enqueue_warn_sta =%d\n"
801 "core_tx_ap_enqueue_warn_nosta =%d\n"
802 "core_tx_ap_enqueue_warn_link =%d\n"
803 "core_tx_ap_enqueue_warn_trigger =%d\n"
804 "core_tx_ap_enqueue_mcast =%d\n"
805 "core_tx_ap_enqueue_ucast =%d\n"
806 "core_tx_ap_enqueue =%d\n"
807 "intf_tx =%d\n"
808 "intf_tx_pending_ac =%d\n"
809 "intf_tx_pending_fw_under_survey =%d\n"
810 "intf_tx_pending_fw_under_linking =%d\n"
811 "intf_tx_pending_xmitbuf =%d\n"
812 "intf_tx_enqueue =%d\n"
813 "core_tx_enqueue =%d\n"
814 "core_tx_enqueue_class =%d\n"
815 "core_tx_enqueue_class_err_sta =%d\n"
816 "core_tx_enqueue_class_err_nosta =%d\n"
817 "core_tx_enqueue_class_err_fwlink =%d\n"
818 "intf_tx_direct =%d\n"
819 "intf_tx_direct_err_coalesce =%d\n"
820 "intf_tx_dequeue =%d\n"
821 "intf_tx_dequeue_err_coalesce =%d\n"
822 "intf_tx_dump_xframe =%d\n"
823 "intf_tx_dump_xframe_err_txdesc =%d\n"
824 "intf_tx_dump_xframe_err_port =%d\n",
825 tx_logs->os_tx,
826 tx_logs->os_tx_err_up,
827 tx_logs->os_tx_err_xmit,
828 tx_logs->os_tx_m2u,
829 tx_logs->os_tx_m2u_ignore_fw_linked,
830 tx_logs->os_tx_m2u_ignore_self,
831 tx_logs->os_tx_m2u_entry,
832 tx_logs->os_tx_m2u_entry_err_xmit,
833 tx_logs->os_tx_m2u_entry_err_skb,
834 tx_logs->os_tx_m2u_stop,
835 tx_logs->core_tx,
836 tx_logs->core_tx_err_pxmitframe,
837 tx_logs->core_tx_err_brtx,
838 tx_logs->core_tx_upd_attrib,
839 tx_logs->core_tx_upd_attrib_adhoc,
840 tx_logs->core_tx_upd_attrib_sta,
841 tx_logs->core_tx_upd_attrib_ap,
842 tx_logs->core_tx_upd_attrib_unknown,
843 tx_logs->core_tx_upd_attrib_dhcp,
844 tx_logs->core_tx_upd_attrib_icmp,
845 tx_logs->core_tx_upd_attrib_active,
846 tx_logs->core_tx_upd_attrib_err_ucast_sta,
847 tx_logs->core_tx_upd_attrib_err_ucast_ap_link,
848 tx_logs->core_tx_upd_attrib_err_sta,
849 tx_logs->core_tx_upd_attrib_err_link,
850 tx_logs->core_tx_upd_attrib_err_sec,
851 tx_logs->core_tx_ap_enqueue_warn_fwstate,
852 tx_logs->core_tx_ap_enqueue_warn_sta,
853 tx_logs->core_tx_ap_enqueue_warn_nosta,
854 tx_logs->core_tx_ap_enqueue_warn_link,
855 tx_logs->core_tx_ap_enqueue_warn_trigger,
856 tx_logs->core_tx_ap_enqueue_mcast,
857 tx_logs->core_tx_ap_enqueue_ucast,
858 tx_logs->core_tx_ap_enqueue,
859 tx_logs->intf_tx,
860 tx_logs->intf_tx_pending_ac,
861 tx_logs->intf_tx_pending_fw_under_survey,
862 tx_logs->intf_tx_pending_fw_under_linking,
863 tx_logs->intf_tx_pending_xmitbuf,
864 tx_logs->intf_tx_enqueue,
865 tx_logs->core_tx_enqueue,
866 tx_logs->core_tx_enqueue_class,
867 tx_logs->core_tx_enqueue_class_err_sta,
868 tx_logs->core_tx_enqueue_class_err_nosta,
869 tx_logs->core_tx_enqueue_class_err_fwlink,
870 tx_logs->intf_tx_direct,
871 tx_logs->intf_tx_direct_err_coalesce,
872 tx_logs->intf_tx_dequeue,
873 tx_logs->intf_tx_dequeue_err_coalesce,
874 tx_logs->intf_tx_dump_xframe,
875 tx_logs->intf_tx_dump_xframe_err_txdesc,
876 tx_logs->intf_tx_dump_xframe_err_port
877 );
878
879 return 0;
880 }
881
proc_get_int_logs(struct seq_file * m,void * v)882 int proc_get_int_logs(struct seq_file *m, void *v)
883 {
884 struct net_device *dev = m->private;
885 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
886
887 DBG_871X_SEL_NL(m,
888 "all =%d\n"
889 "err =%d\n"
890 "tbdok =%d\n"
891 "tbder =%d\n"
892 "bcnderr =%d\n"
893 "bcndma =%d\n"
894 "bcndma_e =%d\n"
895 "rx =%d\n"
896 "rx_rdu =%d\n"
897 "rx_fovw =%d\n"
898 "txfovw =%d\n"
899 "mgntok =%d\n"
900 "highdok =%d\n"
901 "bkdok =%d\n"
902 "bedok =%d\n"
903 "vidok =%d\n"
904 "vodok =%d\n",
905 padapter->int_logs.all,
906 padapter->int_logs.err,
907 padapter->int_logs.tbdok,
908 padapter->int_logs.tbder,
909 padapter->int_logs.bcnderr,
910 padapter->int_logs.bcndma,
911 padapter->int_logs.bcndma_e,
912 padapter->int_logs.rx,
913 padapter->int_logs.rx_rdu,
914 padapter->int_logs.rx_fovw,
915 padapter->int_logs.txfovw,
916 padapter->int_logs.mgntok,
917 padapter->int_logs.highdok,
918 padapter->int_logs.bkdok,
919 padapter->int_logs.bedok,
920 padapter->int_logs.vidok,
921 padapter->int_logs.vodok
922 );
923
924 return 0;
925 }
926
927 #endif /* CONFIG_DBG_COUNTER*/
928
proc_get_rx_signal(struct seq_file * m,void * v)929 int proc_get_rx_signal(struct seq_file *m, void *v)
930 {
931 struct net_device *dev = m->private;
932 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
933
934 DBG_871X_SEL_NL(m, "rssi:%d\n", padapter->recvpriv.rssi);
935 /*DBG_871X_SEL_NL(m, "rxpwdb:%d\n", padapter->recvpriv.rxpwdb);*/
936 DBG_871X_SEL_NL(m, "signal_strength:%u\n", padapter->recvpriv.signal_strength);
937 DBG_871X_SEL_NL(m, "signal_qual:%u\n", padapter->recvpriv.signal_qual);
938 DBG_871X_SEL_NL(m, "noise:%d\n", padapter->recvpriv.noise);
939 rtw_odm_get_perpkt_rssi(m, padapter);
940 #ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
941 rtw_get_raw_rssi_info(m, padapter);
942 #endif
943 return 0;
944 }
945
946
proc_get_hw_status(struct seq_file * m,void * v)947 int proc_get_hw_status(struct seq_file *m, void *v)
948 {
949 struct net_device *dev = m->private;
950 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
951 struct dvobj_priv *dvobj = padapter->dvobj;
952 struct debug_priv *pdbgpriv = &dvobj->drv_dbg;
953
954 DBG_871X_SEL_NL(m, "RX FIFO full count: last_time =%lld, current_time =%lld, differential =%lld\n"
955 , pdbgpriv->dbg_rx_fifo_last_overflow, pdbgpriv->dbg_rx_fifo_curr_overflow, pdbgpriv->dbg_rx_fifo_diff_overflow);
956
957 return 0;
958 }
959
proc_set_rx_signal(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)960 ssize_t proc_set_rx_signal(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
961 {
962 struct net_device *dev = data;
963 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
964 char tmp[32];
965 u32 is_signal_dbg, signal_strength;
966
967 if (count < 1)
968 return -EFAULT;
969
970 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
971
972 int num = sscanf(tmp, "%u %u", &is_signal_dbg, &signal_strength);
973
974 is_signal_dbg = is_signal_dbg == 0?0:1;
975
976 if (is_signal_dbg && num != 2)
977 return count;
978
979 signal_strength = signal_strength > 100?100:signal_strength;
980
981 padapter->recvpriv.is_signal_dbg = is_signal_dbg;
982 padapter->recvpriv.signal_strength_dbg = signal_strength;
983
984 if (is_signal_dbg)
985 DBG_871X("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength);
986 else
987 DBG_871X("set %s\n", "HW_SIGNAL_STRENGTH");
988
989 }
990
991 return count;
992
993 }
994
proc_get_ht_enable(struct seq_file * m,void * v)995 int proc_get_ht_enable(struct seq_file *m, void *v)
996 {
997 struct net_device *dev = m->private;
998 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
999 struct registry_priv *pregpriv = &padapter->registrypriv;
1000
1001 if (pregpriv)
1002 DBG_871X_SEL_NL(m, "%d\n", pregpriv->ht_enable);
1003
1004 return 0;
1005 }
1006
proc_set_ht_enable(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1007 ssize_t proc_set_ht_enable(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1008 {
1009 struct net_device *dev = data;
1010 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1011 struct registry_priv *pregpriv = &padapter->registrypriv;
1012 char tmp[32];
1013 u32 mode;
1014
1015 if (count < 1)
1016 return -EFAULT;
1017
1018 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1019 sscanf(tmp, "%d ", &mode);
1020
1021 if (pregpriv && mode < 2) {
1022 pregpriv->ht_enable = mode;
1023 printk("ht_enable =%d\n", pregpriv->ht_enable);
1024 }
1025 }
1026
1027 return count;
1028
1029 }
1030
proc_get_bw_mode(struct seq_file * m,void * v)1031 int proc_get_bw_mode(struct seq_file *m, void *v)
1032 {
1033 struct net_device *dev = m->private;
1034 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1035 struct registry_priv *pregpriv = &padapter->registrypriv;
1036
1037 if (pregpriv)
1038 DBG_871X_SEL_NL(m, "0x%02x\n", pregpriv->bw_mode);
1039
1040 return 0;
1041 }
1042
proc_set_bw_mode(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1043 ssize_t proc_set_bw_mode(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1044 {
1045 struct net_device *dev = data;
1046 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1047 struct registry_priv *pregpriv = &padapter->registrypriv;
1048 char tmp[32];
1049 u32 mode;
1050
1051 if (count < 1)
1052 return -EFAULT;
1053
1054 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1055 sscanf(tmp, "%d ", &mode);
1056
1057 if (pregpriv && mode < 2) {
1058
1059 pregpriv->bw_mode = mode;
1060 printk("bw_mode =%d\n", mode);
1061
1062 }
1063 }
1064
1065 return count;
1066
1067 }
1068
proc_get_ampdu_enable(struct seq_file * m,void * v)1069 int proc_get_ampdu_enable(struct seq_file *m, void *v)
1070 {
1071 struct net_device *dev = m->private;
1072 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1073 struct registry_priv *pregpriv = &padapter->registrypriv;
1074
1075 if (pregpriv)
1076 DBG_871X_SEL_NL(m, "%d\n", pregpriv->ampdu_enable);
1077
1078 return 0;
1079 }
1080
proc_set_ampdu_enable(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1081 ssize_t proc_set_ampdu_enable(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1082 {
1083 struct net_device *dev = data;
1084 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1085 struct registry_priv *pregpriv = &padapter->registrypriv;
1086 char tmp[32];
1087 u32 mode;
1088
1089 if (count < 1)
1090 return -EFAULT;
1091
1092 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1093
1094 sscanf(tmp, "%d ", &mode);
1095
1096 if (pregpriv && mode < 3) {
1097 pregpriv->ampdu_enable = mode;
1098 printk("ampdu_enable =%d\n", mode);
1099 }
1100
1101 }
1102
1103 return count;
1104
1105 }
1106
proc_get_rx_ampdu(struct seq_file * m,void * v)1107 int proc_get_rx_ampdu(struct seq_file *m, void *v)
1108 {
1109 struct net_device *dev = m->private;
1110 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1111 struct registry_priv *pregpriv = &padapter->registrypriv;
1112 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1113 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1114
1115 if (pregpriv)
1116 DBG_871X_SEL_NL(m,
1117 "accept_addba_req = %d , 0:Reject AP's Add BA req, 1:Accept AP's Add BA req.\n",
1118 pmlmeinfo->accept_addba_req
1119 );
1120
1121 return 0;
1122 }
1123
proc_set_rx_ampdu(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1124 ssize_t proc_set_rx_ampdu(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1125 {
1126 struct net_device *dev = data;
1127 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1128 struct registry_priv *pregpriv = &padapter->registrypriv;
1129 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1130 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1131 char tmp[32];
1132 u32 mode;
1133
1134 if (count < 1)
1135 return -EFAULT;
1136
1137 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1138
1139 sscanf(tmp, "%d ", &mode);
1140
1141 if (pregpriv && mode < 2) {
1142 pmlmeinfo->accept_addba_req = mode;
1143 DBG_871X("pmlmeinfo->accept_addba_req =%d\n",
1144 pmlmeinfo->accept_addba_req);
1145 if (mode == 0) {
1146 /*tear down Rx AMPDU*/
1147 send_delba(padapter, 0, get_my_bssid(&(pmlmeinfo->network)));/* recipient*/
1148 }
1149 }
1150
1151 }
1152
1153 return count;
1154 }
1155
proc_get_en_fwps(struct seq_file * m,void * v)1156 int proc_get_en_fwps(struct seq_file *m, void *v)
1157 {
1158 struct net_device *dev = m->private;
1159 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1160 struct registry_priv *pregpriv = &padapter->registrypriv;
1161
1162 if (pregpriv)
1163 DBG_871X_SEL_NL(m, "check_fw_ps = %d , 1:enable get FW PS state , 0: disable get FW PS state\n"
1164 , pregpriv->check_fw_ps);
1165
1166 return 0;
1167 }
1168
proc_set_en_fwps(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1169 ssize_t proc_set_en_fwps(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1170 {
1171 struct net_device *dev = data;
1172 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1173 struct registry_priv *pregpriv = &padapter->registrypriv;
1174 char tmp[32];
1175 u32 mode;
1176
1177 if (count < 1)
1178 return -EFAULT;
1179
1180 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1181 sscanf(tmp, "%d ", &mode);
1182
1183 if (pregpriv && mode < 2) {
1184 pregpriv->check_fw_ps = mode;
1185 DBG_871X("pregpriv->check_fw_ps =%d\n", pregpriv->check_fw_ps);
1186 }
1187 }
1188 return count;
1189 }
1190
proc_get_rx_stbc(struct seq_file * m,void * v)1191 int proc_get_rx_stbc(struct seq_file *m, void *v)
1192 {
1193 struct net_device *dev = m->private;
1194 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1195 struct registry_priv *pregpriv = &padapter->registrypriv;
1196
1197 if (pregpriv)
1198 DBG_871X_SEL_NL(m, "%d\n", pregpriv->rx_stbc);
1199
1200 return 0;
1201 }
1202
proc_set_rx_stbc(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1203 ssize_t proc_set_rx_stbc(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1204 {
1205 struct net_device *dev = data;
1206 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1207 struct registry_priv *pregpriv = &padapter->registrypriv;
1208 char tmp[32];
1209 u32 mode;
1210
1211 if (count < 1)
1212 return -EFAULT;
1213
1214 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1215 sscanf(tmp, "%d ", &mode);
1216
1217 if (pregpriv && (mode == 0 || mode == 1 ||
1218 mode == 2 || mode == 3)) {
1219 pregpriv->rx_stbc = mode;
1220 printk("rx_stbc =%d\n", mode);
1221 }
1222 }
1223
1224 return count;
1225
1226 }
1227
proc_get_rssi_disp(struct seq_file * m,void * v)1228 int proc_get_rssi_disp(struct seq_file *m, void *v)
1229 {
1230 return 0;
1231 }
1232
proc_set_rssi_disp(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1233 ssize_t proc_set_rssi_disp(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1234 {
1235 struct net_device *dev = data;
1236 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1237 char tmp[32];
1238 u32 enable = 0;
1239
1240 if (count < 1) {
1241 DBG_8192C("argument size is less than 1\n");
1242 return -EFAULT;
1243 }
1244
1245 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
1246 int num = sscanf(tmp, "%x", &enable);
1247
1248 if (num != 1) {
1249 DBG_8192C("invalid set_rssi_disp parameter!\n");
1250 return count;
1251 }
1252
1253 if (enable) {
1254 DBG_8192C("Linked info Function Enable\n");
1255 padapter->bLinkInfoDump = enable;
1256 } else {
1257 DBG_8192C("Linked info Function Disable\n");
1258 padapter->bLinkInfoDump = 0;
1259 }
1260 }
1261 return count;
1262 }
1263
proc_get_all_sta_info(struct seq_file * m,void * v)1264 int proc_get_all_sta_info(struct seq_file *m, void *v)
1265 {
1266 struct net_device *dev = m->private;
1267 struct sta_info *psta;
1268 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
1269 struct sta_priv *pstapriv = &padapter->stapriv;
1270 int i, j;
1271 struct list_head *plist, *phead;
1272 struct recv_reorder_ctrl *preorder_ctrl;
1273
1274 DBG_871X_SEL_NL(m, "sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap);
1275
1276 spin_lock_bh(&pstapriv->sta_hash_lock);
1277
1278 for (i = 0; i < NUM_STA; i++) {
1279 phead = &(pstapriv->sta_hash[i]);
1280 plist = get_next(phead);
1281
1282 while (phead != plist) {
1283 psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
1284
1285 plist = get_next(plist);
1286
1287 DBG_871X_SEL_NL(m, "==============================\n");
1288 DBG_871X_SEL_NL(m, "sta's macaddr:" MAC_FMT "\n",
1289 MAC_ARG(psta->hwaddr));
1290 DBG_871X_SEL_NL(m, "rtsen =%d, cts2slef =%d\n",
1291 psta->rtsen, psta->cts2self);
1292 DBG_871X_SEL_NL(m, "state = 0x%x, aid =%d, macid =%d, raid =%d\n",
1293 psta->state, psta->aid, psta->mac_id,
1294 psta->raid);
1295 DBG_871X_SEL_NL(m, "qos_en =%d, ht_en =%d, init_rate =%d\n",
1296 psta->qos_option,
1297 psta->htpriv.ht_option,
1298 psta->init_rate);
1299 DBG_871X_SEL_NL(m, "bwmode =%d, ch_offset =%d, sgi_20m =%d, sgi_40m =%d\n",
1300 psta->bw_mode, psta->htpriv.ch_offset,
1301 psta->htpriv.sgi_20m,
1302 psta->htpriv.sgi_40m);
1303 DBG_871X_SEL_NL(m, "ampdu_enable = %d\n",
1304 psta->htpriv.ampdu_enable);
1305 DBG_871X_SEL_NL(m, "agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n",
1306 psta->htpriv.agg_enable_bitmap,
1307 psta->htpriv.candidate_tid_bitmap);
1308 DBG_871X_SEL_NL(m, "sleepq_len =%d\n",
1309 psta->sleepq_len);
1310 DBG_871X_SEL_NL(m, "sta_xmitpriv.vo_q_qcnt =%d\n",
1311 psta->sta_xmitpriv.vo_q.qcnt);
1312 DBG_871X_SEL_NL(m, "sta_xmitpriv.vi_q_qcnt =%d\n",
1313 psta->sta_xmitpriv.vi_q.qcnt);
1314 DBG_871X_SEL_NL(m, "sta_xmitpriv.be_q_qcnt =%d\n",
1315 psta->sta_xmitpriv.be_q.qcnt);
1316 DBG_871X_SEL_NL(m, "sta_xmitpriv.bk_q_qcnt =%d\n",
1317 psta->sta_xmitpriv.bk_q.qcnt);
1318
1319 DBG_871X_SEL_NL(m, "capability = 0x%x\n",
1320 psta->capability);
1321 DBG_871X_SEL_NL(m, "flags = 0x%x\n", psta->flags);
1322 DBG_871X_SEL_NL(m, "wpa_psk = 0x%x\n", psta->wpa_psk);
1323 DBG_871X_SEL_NL(m, "wpa2_group_cipher = 0x%x\n",
1324 psta->wpa2_group_cipher);
1325 DBG_871X_SEL_NL(m, "wpa2_pairwise_cipher = 0x%x\n",
1326 psta->wpa2_pairwise_cipher);
1327 DBG_871X_SEL_NL(m, "qos_info = 0x%x\n", psta->qos_info);
1328 DBG_871X_SEL_NL(m, "dot118021XPrivacy = 0x%x\n",
1329 psta->dot118021XPrivacy);
1330
1331 for (j = 0; j < 16; j++) {
1332 preorder_ctrl = &psta->recvreorder_ctrl[j];
1333 if (preorder_ctrl->enable)
1334 DBG_871X_SEL_NL(m, "tid =%d, indicate_seq =%d\n",
1335 j, preorder_ctrl->indicate_seq);
1336 }
1337 DBG_871X_SEL_NL(m, "==============================\n");
1338 }
1339 }
1340
1341 spin_unlock_bh(&pstapriv->sta_hash_lock);
1342
1343 return 0;
1344 }
1345
proc_get_btcoex_dbg(struct seq_file * m,void * v)1346 int proc_get_btcoex_dbg(struct seq_file *m, void *v)
1347 {
1348 struct net_device *dev = m->private;
1349 struct adapter *padapter;
1350 char buf[512] = {0};
1351 padapter = (struct adapter *)rtw_netdev_priv(dev);
1352
1353 rtw_btcoex_GetDBG(padapter, buf, 512);
1354
1355 DBG_871X_SEL(m, "%s", buf);
1356
1357 return 0;
1358 }
1359
proc_set_btcoex_dbg(struct file * file,const char __user * buffer,size_t count,loff_t * pos,void * data)1360 ssize_t proc_set_btcoex_dbg(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
1361 {
1362 struct net_device *dev = data;
1363 struct adapter *padapter;
1364 u8 tmp[80] = {0};
1365 u32 module[2] = {0};
1366 u32 num;
1367
1368 padapter = (struct adapter *)rtw_netdev_priv(dev);
1369
1370 /* DBG_871X("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter));*/
1371
1372 if (NULL == buffer) {
1373 DBG_871X(FUNC_ADPT_FMT ": input buffer is NULL!\n",
1374 FUNC_ADPT_ARG(padapter));
1375
1376 return -EFAULT;
1377 }
1378
1379 if (count < 1) {
1380 DBG_871X(FUNC_ADPT_FMT ": input length is 0!\n",
1381 FUNC_ADPT_ARG(padapter));
1382
1383 return -EFAULT;
1384 }
1385
1386 num = count;
1387 if (num > (sizeof(tmp) - 1))
1388 num = (sizeof(tmp) - 1);
1389
1390 if (copy_from_user(tmp, buffer, num)) {
1391 DBG_871X(FUNC_ADPT_FMT ": copy buffer from user space FAIL!\n",
1392 FUNC_ADPT_ARG(padapter));
1393
1394 return -EFAULT;
1395 }
1396
1397 num = sscanf(tmp, "%x %x", module, module+1);
1398 if (1 == num) {
1399 if (0 == module[0])
1400 memset(module, 0, sizeof(module));
1401 else
1402 memset(module, 0xFF, sizeof(module));
1403 } else if (2 != num) {
1404 DBG_871X(FUNC_ADPT_FMT ": input(\"%s\") format incorrect!\n",
1405 FUNC_ADPT_ARG(padapter), tmp);
1406
1407 if (0 == num)
1408 return -EFAULT;
1409 }
1410
1411 DBG_871X(FUNC_ADPT_FMT ": input 0x%08X 0x%08X\n",
1412 FUNC_ADPT_ARG(padapter), module[0], module[1]);
1413 rtw_btcoex_SetDBG(padapter, module);
1414
1415 return count;
1416 }
1417
proc_get_btcoex_info(struct seq_file * m,void * v)1418 int proc_get_btcoex_info(struct seq_file *m, void *v)
1419 {
1420 struct net_device *dev = m->private;
1421 struct adapter *padapter;
1422 const u32 bufsize = 30*100;
1423 u8 *pbuf = NULL;
1424
1425 padapter = (struct adapter *)rtw_netdev_priv(dev);
1426
1427 pbuf = rtw_zmalloc(bufsize);
1428 if (NULL == pbuf) {
1429 return -ENOMEM;
1430 }
1431
1432 rtw_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize);
1433
1434 DBG_871X_SEL(m, "%s\n", pbuf);
1435
1436 kfree(pbuf);
1437
1438 return 0;
1439 }
1440
1441 #endif
1442