1 #include "ecrnx_debugfs_custom.h"
2 #include "ecrnx_debugfs_func.h"
3 #include "slave_log_buf.h"
4 #include <linux/file.h>
6 #ifdef CONFIG_ECRNX_DEBUGFS
7 #define DEFINE_SHOW_ATTRIBUTE(__name) \
8 static int __name ## _open(struct inode *inode, struct file *file) \
10 return single_open(file, __name ## _show, inode->i_private); \
13 static const struct file_operations __name ## _fops = { \
14 .owner = THIS_MODULE, \
15 .open = __name ## _open, \
17 .llseek = seq_lseek, \
18 .release = single_release, \
21 #define DEFINE_SHOW_ATTRIBUTE_EX(__name) \
22 static int __name ## _open(struct inode *inode, struct file *file) \
24 return single_open(file, __name ## _show, inode->i_private); \
27 static const struct file_operations __name ## _fops = { \
28 .owner = THIS_MODULE, \
29 .open = __name ## _open, \
31 .write = __name ## _write, \
32 .llseek = seq_lseek, \
33 .release = single_release, \
36 static long custom_sys_write(unsigned int fd, const char __user *buf, size_t count)
39 struct file *file = NULL;
44 printk("Write buffer was empty.\n");
48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
53 ret = kernel_write(file, buf, count, (loff_t *)&offset);
55 ret = kernel_write(file, buf, count, 0);
61 print_hex_dump(KERN_DEBUG, DBG_PREFIX, DUMP_PREFIX_NONE, 16, 1, buf, count, false);
67 void seq_reg_display_u32(struct seq_file *seq, u32 addr, u32 *reg, u32 len)
74 seq_printf(seq, "0x%08X ", (addr+ 4*i));
76 seq_printf(seq, " 0x%08X", reg[i]);
79 seq_printf(seq, "\n");
83 seq_printf(seq, "\n");
86 void seq_reg_display_u8(struct seq_file *seq, u32 addr, u8 *reg, u32 len)
93 seq_printf(seq, "0x%04X ", (addr+i)&0xFFFF);
95 seq_printf(seq, " %02X", reg[i]);
101 seq_printf(seq, "\n");
105 seq_printf(seq, "\n");
107 void read_reg_display_u32(u32 addr, u32 *reg, u32 len)
110 u32 size = len*11 + (len + 3)/4*16 + len/4;
114 buf = kmalloc(size, GFP_ATOMIC);
119 for (i=0; i<len; i++)
123 sprintf(buf+point,"addr:0x%08X", (addr+ 4*i));
130 sprintf(buf+point,"0x%08X", reg[i]);
142 custom_sys_write(0,buf,size);
151 void reg_display_u32(u32 addr, u32 *reg, u32 len)
155 for (i=0; i<len; i++)
158 ECRNX_PRINT("0x%08X", (addr+ 4*i));
160 ECRNX_PRINT("0x%08X", reg[i]);
170 void reg_display_u8(u32 addr, u8 *reg, u32 len)
174 for (i=0; i<len; i++)
177 ECRNX_PRINT("0x%04X ", (addr+i)&0xFFFF);
179 ECRNX_PRINT(" %02X", reg[i]);
192 static int drv_cfg_show(struct seq_file *seq, void *v)
194 //#define DRV_CFG_DETAILS
198 ecrnx_host_ver_get(host_ver);
200 seq_printf(seq, "Kernel Version : %d.%d.%d\n", LINUX_VERSION_CODE >> 16, (LINUX_VERSION_CODE >> 8)&0xFF, LINUX_VERSION_CODE&0xFF);
201 seq_printf(seq, "Driver Version : %s\n", host_ver);
202 seq_printf(seq, "------------------------------------------------\n");
204 #ifdef CONFIG_ECRNX_ESWIN
205 seq_printf(seq, "CONFIG_ECRNX_ESWIN=1\n");
207 #ifdef DRV_CFG_DETAILS
208 seq_printf(seq, "CONFIG_ECRNX_ESWIN=0\n");
213 #ifdef CONFIG_ECRNX_FULLMAC
214 seq_printf(seq, "CONFIG_ECRNX_FULLMAC=1\n");
216 #ifdef DRV_CFG_DETAILS
217 seq_printf(seq, "CONFIG_ECRNX_FULLMAC=0\n");
222 #ifdef CONFIG_ECRNX_SOFTMAC
223 seq_printf(seq, "CONFIG_ECRNX_SOFTMAC=1\n");
225 #ifdef DRV_CFG_DETAILS
226 seq_printf(seq, "CONFIG_ECRNX_SOFTMAC=0\n");
231 #ifdef CONFIG_ECRNX_ESWIN_USB
232 seq_printf(seq, "CONFIG_ECRNX_ESWIN_USB=1\n");
234 #ifdef DRV_CFG_DETAILS
235 seq_printf(seq, "CONFIG_ECRNX_ESWIN_USB=0\n");
240 #ifdef CONFIG_ECRNX_ESWIN_SDIO
241 seq_printf(seq, "CONFIG_ECRNX_ESWIN_SDIO=1\n");
243 #ifdef DRV_CFG_DETAILS
244 seq_printf(seq, "CONFIG_ECRNX_ESWIN_SDIO=0\n");
249 #ifdef CONFIG_ECRNX_HE
250 seq_printf(seq, "CONFIG_ECRNX_HE=1\n");
252 #ifdef DRV_CFG_DETAILS
253 seq_printf(seq, "CONFIG_ECRNX_HE=0\n");
258 #ifdef CONFIG_ECRNX_P2P
259 seq_printf(seq, "CONFIG_ECRNX_P2P=1\n");
261 #ifdef DRV_CFG_DETAILS
262 seq_printf(seq, "CONFIG_ECRNX_P2P=0\n");
267 #ifdef CONFIG_ECRNX_FHOST
268 seq_printf(seq, "CONFIG_ECRNX_FHOST=1\n");
270 #ifdef DRV_CFG_DETAILS
271 seq_printf(seq, "CONFIG_ECRNX_FHOST=0\n");
276 #ifdef CONFIG_ECRNX_SDM
277 seq_printf(seq, "CONFIG_ECRNX_SDM=1\n");
279 #ifdef DRV_CFG_DETAILS
280 seq_printf(seq, "CONFIG_ECRNX_SDM=0\n");
285 #ifdef CONFIG_ECRNX_TL4
286 seq_printf(seq, "CONFIG_ECRNX_TL4=1\n");
288 #ifdef DRV_CFG_DETAILS
289 seq_printf(seq, "CONFIG_ECRNX_TL4=0\n");
294 #ifdef CONFIG_ECRNX_MUMIMO_TX
295 seq_printf(seq, "CONFIG_ECRNX_MUMIMO_TX=1\n");
297 #ifdef DRV_CFG_DETAILS
298 seq_printf(seq, "CONFIG_ECRNX_MUMIMO_TX=0\n");
303 #ifdef CONFIG_ECRNX_RADAR
304 seq_printf(seq, "CONFIG_ECRNX_RADAR=1\n");
306 #ifdef DRV_CFG_DETAILS
307 seq_printf(seq, "CONFIG_ECRNX_RADAR=0\n");
312 #ifdef CONFIG_ECRNX_BCMC
313 seq_printf(seq, "CONFIG_ECRNX_BCMC=1\n");
315 #ifdef DRV_CFG_DETAILS
316 seq_printf(seq, "CONFIG_ECRNX_BCMC=0\n");
321 #ifdef CONFIG_ECRNX_MON_DATA
322 seq_printf(seq, "CONFIG_ECRNX_MON_DATA=1\n");
324 #ifdef DRV_CFG_DETAILS
325 seq_printf(seq, "CONFIG_ECRNX_MON_DATA=0\n");
330 #ifdef CONFIG_ECRNX_SW_PROFILING
331 seq_printf(seq, "CONFIG_ECRNX_SW_PROFILING=1\n");
333 #ifdef DRV_CFG_DETAILS
334 seq_printf(seq, "CONFIG_ECRNX_SW_PROFILING=0\n");
339 #ifdef CONFIG_ECRNX_DBG
340 seq_printf(seq, "CONFIG_ECRNX_DBG=1\n");
342 #ifdef DRV_CFG_DETAILS
343 seq_printf(seq, "CONFIG_ECRNX_DBG=0\n");
348 #ifdef CFG_WOW_SUPPORT
349 seq_printf(seq, "CFG_WOW_SUPPORT=1\n");
351 #ifdef DRV_CFG_DETAILS
352 seq_printf(seq, "CFG_WOW_SUPPORT=0\n");
358 DEFINE_SHOW_ATTRIBUTE(drv_cfg);
361 static int log_level_show(struct seq_file *seq, void *v)
365 if (0 == ecrnx_log_level_get(&log))
366 seq_printf(seq, "log_level:%d dir:%d\n", log.level, log.dir);
368 seq_printf(seq, "\n");
373 static ssize_t log_level_write(struct file *filp, const char __user *buffer,
374 size_t count, loff_t *ppos)
379 if (count > 6) // 255:0\n
382 if (0 != copy_from_user(kbuf, buffer, count))
384 sscanf(kbuf, "%d:%d\n", &level, &dir);
389 ecrnx_fw_log_level_set(level, dir);
393 DEFINE_SHOW_ATTRIBUTE_EX(log_level);
395 static ssize_t mac_log_read(struct file *file , char __user *user_buf,
396 size_t count, loff_t *ppos)
398 struct ring_buffer *buf_handle;
401 if (false == ecrnx_log_host_enable())
403 #ifdef CONFIG_ECRNX_ESWIN_USB
404 buf_handle = usb_dbg_buf_get();
405 ring_buffer_scrolling_display(buf_handle,true);
406 while(buf_handle->show)
408 len = ring_buffer_len(buf_handle);
410 //ECRNX_PRINT("mac_log_read len:%d %d %d", len,buf_handle->write_point, buf_handle->read_point);
413 ring_buffer_get(buf_handle,buf,len);
414 custom_sys_write(0,buf,len);
428 static ssize_t mac_log_write(struct file *filp, const char __user *buffer,
429 size_t count, loff_t *ppos)
433 struct ring_buffer *buf_handle;
435 if (count > 2) // 255:0\n
438 if (0 != copy_from_user(kbuf, buffer, count))
440 sscanf(kbuf, "%d:%d\n", &show);
441 #ifdef CONFIG_ECRNX_ESWIN_USB
444 buf_handle = usb_dbg_buf_get();
445 ring_buffer_scrolling_display(buf_handle, false);
452 static const struct file_operations new_mac_log_fops = { \
453 .read = mac_log_read, \
454 .write = mac_log_write, \
457 static int ver_info_show(struct seq_file *seq, void *v)
462 ecrnx_host_ver_get(host_ver);
463 ecrnx_build_time_get(build_time);
465 seq_printf(seq, "%s\n", host_ver);
466 seq_printf(seq, "build time: %s\n", build_time);
470 DEFINE_SHOW_ATTRIBUTE(ver_info);
472 extern bin_head_data head;
473 static int fw_info_show(struct seq_file *seq, void *v)
475 struct tm timenow = {0};
477 localtime(&timenow, head.UTC_time);
478 if(head.fw_Info != NULL)
480 seq_printf(seq, "sdk_verson:%s\n", head.fw_Info);
482 seq_printf(seq, "fw_crc:0x%8x\n", head.crc32);
483 seq_printf(seq, "fw_build_time: %04d-%02d-%02d %02d:%02d:%02d\n",(int)timenow.tm_year,timenow.tm_mon,timenow.tm_mday,timenow.tm_hour,timenow.tm_min,timenow.tm_sec);
487 DEFINE_SHOW_ATTRIBUTE(fw_info);
489 struct dentry *ecr6600u_dir = NULL;
490 struct dentry *drv_cfg, *log_level, *mac_log, *ver_info, *fw_info;
492 int ecrnx_debugfs_info_init(void *private_data)
494 ecr6600u_dir = debugfs_create_dir("ecr6600u", NULL);
498 drv_cfg = debugfs_create_file("drv_cfg", 0444, ecr6600u_dir, private_data, &drv_cfg_fops);
502 log_level = debugfs_create_file("log_level", 0666, ecr6600u_dir, private_data, &log_level_fops);
506 mac_log = debugfs_create_file("maclog", 0444, ecr6600u_dir, private_data, &new_mac_log_fops);
510 ver_info = debugfs_create_file("ver_info", 0444, ecr6600u_dir, private_data, &ver_info_fops);
514 fw_info = debugfs_create_file("fw_info", 0444, ecr6600u_dir, private_data, &fw_info_fops);
524 static int rf_info_show(struct seq_file *seq, void *v)
526 RF_INFO_ST cur, oper;
528 if (0 == ecrnx_rf_info_get(seq, IF_STA, &cur, &oper))
530 seq_printf(seq, "cur_ch=%d, cur_bw=%d, cur_ch_offset=%d\n", cur.ch, cur.bw, cur.ch_offset);
531 // seq_printf(seq, "oper_ch=%d, oper_bw=%d, oper_ch_offset=%d\n", oper.ch, oper.bw, oper.ch_offset);
536 DEFINE_SHOW_ATTRIBUTE(rf_info);
538 static int mac_reg_dump_show(struct seq_file *seq, void *v)
540 ecrnx_mac_reg_dump(seq);
544 DEFINE_SHOW_ATTRIBUTE(mac_reg_dump);
546 static int rf_reg_dump_show(struct seq_file *seq, void *v)
548 ecrnx_rf_reg_dump(seq);
552 DEFINE_SHOW_ATTRIBUTE(rf_reg_dump);
554 static int bb_reg_dump_show(struct seq_file *seq, void *v)
556 ecrnx_bb_reg_dump(seq);
560 DEFINE_SHOW_ATTRIBUTE(bb_reg_dump);
562 static int country_code_show(struct seq_file *seq, void *v)
564 char country_code[3];
565 if (0 == ecrnx_country_code_get(seq, country_code))
567 seq_printf(seq, "%s\n", country_code);
571 seq_printf(seq, "UNSPECIFIED\n");
576 DEFINE_SHOW_ATTRIBUTE(country_code);
578 static int mac_addr_show(struct seq_file *seq, void *v)
580 u8 mac_addr_info[128];
582 if (0 == ecrnx_mac_addr_get_ex(seq, mac_addr_info))
584 seq_printf(seq, "%s", mac_addr_info);
588 seq_printf(seq, "--\n");
593 DEFINE_SHOW_ATTRIBUTE(mac_addr);
595 static int efuse_map_show(struct seq_file *seq, void *v)
597 ecrnx_efuse_map_dump(seq);
601 DEFINE_SHOW_ATTRIBUTE(efuse_map);
603 static int read_reg_show(struct seq_file *seq, void *v)
607 static ssize_t read_reg_write(struct file *filp, const char __user *buffer,
608 size_t count, loff_t *ppos)
613 char * read_reg_buf = NULL;
615 if (count > sizeof(kbuf))
618 if (0 != copy_from_user(kbuf, buffer, count))
621 ret_code = sscanf(kbuf, "0x%x %d\n", &addr, &len);
624 ECRNX_ERR("Parameter error.\n");
630 ECRNX_ERR("Address is invalid.\n");
634 if (0 == ecrnx_slave_reg_read(addr, reg_buf, len * sizeof(reg_buf[0])))
635 read_reg_display_u32(addr, reg_buf, len);
638 DEFINE_SHOW_ATTRIBUTE_EX(read_reg);
639 static int write_reg_show(struct seq_file *seq, void *v)
644 static ssize_t write_reg_write(struct file *filp, const char __user *buffer,
645 size_t count, loff_t *ppos)
649 int ret_code,ret = count;
650 char* write_reg_result = NULL;
652 if (count > sizeof(kbuf))
655 if (0 != copy_from_user(kbuf, buffer, count))
658 ret_code = sscanf(kbuf, "0x%x 0x%x\n", &addr, &data);
661 write_reg_result = "Parameter error.\n";
667 write_reg_result = "Address is invalid.\n";
671 if (0 != ecrnx_slave_reg_write(addr, data, 1))
673 write_reg_result = "Write error.\n";
677 write_reg_result = "Write success.\n";
678 if(write_reg_result != NULL)
680 custom_sys_write(0,write_reg_result,strlen(write_reg_result));
684 DEFINE_SHOW_ATTRIBUTE_EX(write_reg);
686 static int rf_tx_rx_info_show(struct seq_file *seq, void *v)
689 // u8 cli[]="rf_get_rssi 0 1 2";
691 // ecrnx_slave_cli_send(cli, resp);
696 static ssize_t rf_tx_rx_info_write(struct file *filp, const char __user *buffer,
697 size_t count, loff_t *ppos)
701 if (count > sizeof(kbuf))
704 if (0 != copy_from_user(kbuf, buffer, count))
712 DEFINE_SHOW_ATTRIBUTE_EX(rf_tx_rx_info);
714 struct dentry *hw_dir = NULL;
715 struct dentry *hw_rf_info, *hw_mac_reg_dump, *hw_rf_reg_dump, *hw_bb_reg_dump, *hw_country_code, *hw_mac_addr;
716 struct dentry *hw_efuse_map, *hw_read_reg, *hw_write_reg, *hw_rf_tx_rx_info;
718 int ecrnx_debugfs_hw_init(void *private_data)
723 hw_dir = debugfs_create_dir("hw", ecr6600u_dir);
727 hw_rf_info = debugfs_create_file("rf_info", 0444, hw_dir, private_data, &rf_info_fops);
731 hw_mac_reg_dump = debugfs_create_file("mac_reg_dump", 0444, hw_dir, private_data, &mac_reg_dump_fops);
732 if (!hw_mac_reg_dump)
735 hw_rf_reg_dump = debugfs_create_file("rf_reg_dump", 0444, hw_dir, private_data, &rf_reg_dump_fops);
739 hw_bb_reg_dump = debugfs_create_file("bb_reg_dump", 0444, hw_dir, private_data, &bb_reg_dump_fops);
743 hw_country_code = debugfs_create_file("country_code", 0444, hw_dir, private_data, &country_code_fops);
744 if (!hw_country_code)
747 hw_mac_addr = debugfs_create_file("mac_addr", 0444, hw_dir, private_data, &mac_addr_fops);
751 hw_efuse_map = debugfs_create_file("efuse_map", 0444, hw_dir, private_data, &efuse_map_fops);
755 hw_read_reg = debugfs_create_file("read_reg", 0222, hw_dir, private_data, &read_reg_fops);
759 hw_write_reg = debugfs_create_file("write_reg", 0222, hw_dir, private_data, &write_reg_fops);
763 hw_rf_tx_rx_info = debugfs_create_file("rf_tx_rx_info", 0666, hw_dir, private_data, &rf_tx_rx_info_fops);
764 if (!hw_rf_tx_rx_info)
770 debugfs_remove_recursive(hw_dir);
776 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
779 #define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5]
782 static int survey_info_show(struct seq_file *seq, void *v)
785 struct ecrnx_hw *ecrnx_hw;
786 struct ecrnx_debugfs_survey_info_tbl *entry;
788 if (seq->private != NULL)
789 ecrnx_hw = seq->private;
793 //seq_printf(seq, "index bssid ch RSSI SdBm Noise age flag ssid \n");
794 seq_printf(seq, "%5s %-17s %3s %-3s %-4s %-4s %5s %32s %32s\n", "index", "bssid", "ch", "RSSI", "SdBm", "Noise", "age", "flag", "ssid");
796 list_for_each_entry(entry, &ecrnx_hw->debugfs_survey_info_tbl_ptr, list) {
797 seq_printf(seq, "%5d "MAC_FMT" %3d %3d %4d %4d %5d %32s %32s\n",
799 MAC_ARG(entry->bssid),
811 DEFINE_SHOW_ATTRIBUTE(survey_info);
813 static int sta_info_show(struct seq_file *seq, void *v)
816 struct cfg80211_chan_def chandef;
817 u32 bw_array[]={20, 20, 40, 80, 80, 160, 5, 10};
819 if (0 == ecrnx_signal_level_get(seq, IF_STA, &noise_dbm))
820 seq_printf(seq, "signal level : %d dBm\n", noise_dbm);
822 seq_printf(seq, "signal level : \n");
824 if (0 == ecrnx_channel_get(seq, IF_STA, &chandef))
826 seq_printf(seq, "frequency : %d MHz\n", chandef.center_freq1);
827 seq_printf(seq, "bandwidth : %d MHz\n", bw_array[chandef.width]);
831 seq_printf(seq, "frequency : \n");
832 seq_printf(seq, "bandwidth : \n");
837 DEFINE_SHOW_ATTRIBUTE(sta_info);
839 static int ht_info_show(struct seq_file *seq, void *v)
841 struct cfg80211_chan_def chandef;
842 u32 bw_array[]={20, 20, 40, 80, 80, 160, 5, 10};
844 if (0 == ecrnx_channel_get(seq, IF_STA, &chandef))
845 seq_printf(seq, "bandwidth : %d MHz\n", bw_array[chandef.width]);
847 seq_printf(seq, "bandwidth : \n");
851 DEFINE_SHOW_ATTRIBUTE(ht_info);
854 struct dentry *wlan0_dir = NULL;
855 struct dentry *wlan0_survey_info, *wlan0_sta_info, *wlan0_ht_info;;
857 int ecrnx_debugfs_wlan0_init(void *private_data)
862 wlan0_dir = debugfs_create_dir("wlan0", ecr6600u_dir);
866 wlan0_survey_info = debugfs_create_file("survey_info", 0444, wlan0_dir, private_data, &survey_info_fops);
867 if (!wlan0_survey_info)
870 wlan0_sta_info = debugfs_create_file("sta_info", 0444, wlan0_dir, private_data, &sta_info_fops);
874 wlan0_ht_info = debugfs_create_file("ht_info", 0444, wlan0_dir, private_data, &ht_info_fops);
881 debugfs_remove_recursive(wlan0_dir);
886 static int ap_info_show(struct seq_file *seq, void *v)
888 struct cfg80211_chan_def chandef;
889 u32 bw_array[]={20, 20, 40, 80, 80, 160, 5, 10};
890 u8 ssid[IEEE80211_MAX_SSID_LEN];
891 u8 sta_mac[NX_REMOTE_STA_MAX][ETH_ALEN+1];
894 seq_printf(seq, "AP Vendor ESWIN\n");
896 seq_printf(seq, "ap info\n");
897 if (0 == ecrnx_ssid_get(seq, IF_AP, ssid))
898 seq_printf(seq, "ssid : %s\n", ssid);
900 seq_printf(seq, "ssid : \n");
902 if (0 == ecrnx_channel_get(seq, IF_AP, &chandef))
904 seq_printf(seq, "cur_channel=%d, cur_bwmode=%d(%dMHz), cur_ch_offset=0\n",
905 (chandef.center_freq1 - 2412)/5 + 1, chandef.width, bw_array[chandef.width]);
909 seq_printf(seq, "cur_channel=, cur_bwmode=(MHz), cur_ch_offset=\n");
911 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
912 if ((chandef.width <= NL80211_CHAN_WIDTH_10) && (chandef.width >= NL80211_CHAN_WIDTH_20_NOHT))
914 if (NL80211_CHAN_WIDTH_20_NOHT == chandef.width)
916 seq_printf(seq, "ht_en=0\n");
920 seq_printf(seq, "ht_en=1\n");
925 seq_printf(seq, "ht_en=0\n");
929 seq_printf(seq, "wireless_mode=0xb(B/G/N), rtsen=0, cts2slef=0\n");
930 seq_printf(seq, "state=0x10, aid=0, macid=32, raid=0\n");
931 seq_printf(seq, "qos_en=1, init_rate=0\n");
932 seq_printf(seq, "bwmode=0, ch_offset=0, sgi_20m=1,sgi_40m=1\n");
933 seq_printf(seq, "ampdu_enable = 1\n");
934 seq_printf(seq, "agg_enable_bitmap=0, candidate_tid_bitmap=0\n");
935 seq_printf(seq, "ldpc_cap=0x0, stbc_cap=0x0, beamform_cap=0x0\n");
938 seq_printf(seq, "\n");
939 seq_printf(seq, "station info\n");
940 memset(sta_mac, 0x00, sizeof(sta_mac));
941 if (0 == ecrnx_sta_mac_get(seq, IF_AP, sta_mac))
943 for (i=0; i<NX_REMOTE_STA_MAX; i++)
946 seq_printf(seq, "sta's macaddr:%02X:%02X:%02X:%02X:%02X:%02X\n", sta_mac[i][1], sta_mac[i][2],
947 sta_mac[i][3], sta_mac[i][4], sta_mac[i][5], sta_mac[i][6]);
953 DEFINE_SHOW_ATTRIBUTE(ap_info);
955 static int sta_info_in_ap_show(struct seq_file *seq, void *v)
957 struct ecrnx_debugfs_sta *sta;
959 if (seq->private == NULL)
960 ECRNX_ERR("error sta_info_in_ap_show\n");
964 seq_printf(seq, "cur_channel=%d, cur_bwmode=%d\n", sta->ch_idx, sta->width);
965 //seq_printf(m, "wireless_mode=0x%x(%s), rtsen=%d, cts2slef=%d\n", psta->wireless_mode, wl_mode, psta->rtsen, psta->cts2self);
966 seq_printf(seq, "aid=%d\n", sta->aid);
968 seq_printf(seq, "qos_en=%d, ht_en=%d\n", sta->qos, sta->ht);
969 seq_printf(seq, "sgi_20m=%d,sgi_40m=%d\n", sta->sgi_20m, sta->sgi_40m);
970 seq_printf(seq, "ampdu_enable = %d\n", sta->ampdu_enable);
971 seq_printf(seq, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", sta->agg_enable_bitmap, sta->candidate_tid_bitmap);
972 seq_printf(seq, "ldpc_cap=0x%x, stbc_cap=0x%x, beamform_cap=0x%x\n", sta->ldpc_cap, sta->stbc_cap, sta->beamform_cap);
976 DEFINE_SHOW_ATTRIBUTE(sta_info_in_ap);
978 struct dentry *ap0_dir = NULL;
979 struct dentry *ap0_ap_info;
980 struct dentry *stas[NX_REMOTE_STA_MAX];
982 int ecrnx_debugfs_ap0_init(void *private_data)
987 ap0_dir = debugfs_create_dir("ap0", ecr6600u_dir);
991 ap0_ap_info = debugfs_create_file("ap_info", 0444, ap0_dir, private_data, &ap_info_fops);
998 debugfs_remove_recursive(ap0_dir);
1003 void ecrnx_debugfs_sta_in_ap_init(void *private_data)
1007 struct ecrnx_debugfs_sta *sta;
1010 index = sta->sta_idx;
1012 sprintf(file_name, "%02x-%02x-%02x-%02x-%02x-%02x", MAC_ARG(sta->mac_addr));
1013 stas[index] = debugfs_create_file(file_name, 0444, ap0_dir, private_data, &sta_info_in_ap_fops);
1014 ECRNX_PRINT("%s:file_name: %s, sta idx:%d,stas:0x%p \n", __func__, file_name, sta->sta_idx, stas[index]);
1017 void ecrnx_debugfs_sta_in_ap_del(u8 sta_idx)
1019 struct dentry *dentry_sta;
1020 struct ecrnx_debugfs_sta *debugfs_sta;
1022 ECRNX_PRINT("%s: sta_idx:%d, stas:0x%p \n", __func__, sta_idx, stas[sta_idx]);
1023 dentry_sta = stas[sta_idx];
1026 ECRNX_ERR("error sta_idx!!!\n");
1030 if (dentry_sta->d_inode)
1032 debugfs_sta = dentry_sta->d_inode->i_private;
1033 ECRNX_DBG("%s: dentry_sta->d_inode:0x%p, debugfs_sta:0x%p \n", __func__, dentry_sta->d_inode, debugfs_sta);
1036 debugfs_remove(dentry_sta);
1041 stas[sta_idx] = NULL;
1044 static int p2p0_survey_info_show(struct seq_file *seq, void *v)
1046 survey_info_show(seq, v);
1050 DEFINE_SHOW_ATTRIBUTE(p2p0_survey_info);
1052 static int p2p_info_show(struct seq_file *seq, void *v)
1055 struct cfg80211_chan_def chandef;
1056 u32 bw_array[]={20, 20, 40, 80, 80, 160, 5, 10};
1058 if (0 == ecrnx_signal_level_get(seq, IF_P2P, &noise_dbm))
1059 seq_printf(seq, "signal level : %d dBm\n", noise_dbm);
1061 seq_printf(seq, "signal level : \n");
1063 if (0 == ecrnx_channel_get(seq, IF_P2P, &chandef))
1065 seq_printf(seq, "frequency : %d MHz\n", chandef.center_freq1);
1066 seq_printf(seq, "bandwidth : %d MHz\n", bw_array[chandef.width]);
1070 seq_printf(seq, "frequency : \n");
1071 seq_printf(seq, "bandwidth : \n");
1074 if (NL80211_IFTYPE_P2P_CLIENT == ecrnx_p2p_role_get(seq, IF_P2P))
1076 seq_printf(seq, "type : P2P-client\n");
1078 else if(NL80211_IFTYPE_P2P_GO == ecrnx_p2p_role_get(seq, IF_P2P))
1080 seq_printf(seq, "type : P2P-GO\n");
1084 seq_printf(seq, "type : \n");
1089 DEFINE_SHOW_ATTRIBUTE(p2p_info);
1091 static int p2p0_ht_info_show(struct seq_file *seq, void *v)
1093 struct cfg80211_chan_def chandef;
1094 u32 bw_array[]={20, 20, 40, 80, 80, 160, 5, 10};
1096 if (0 == ecrnx_channel_get(seq, IF_P2P, &chandef))
1097 seq_printf(seq, "bandwidth : %d MHz\n", bw_array[chandef.width]);
1099 seq_printf(seq, "bandwidth : \n");
1103 DEFINE_SHOW_ATTRIBUTE(p2p0_ht_info);
1105 struct dentry *p2p0_dir = NULL;
1106 struct dentry *p2p0_survey_info, *p2p0_p2p_info, *p2p0_ht_info;
1108 int ecrnx_debugfs_p2p0_init(void *private_data)
1113 p2p0_dir = debugfs_create_dir("p2p0", ecr6600u_dir);
1117 p2p0_survey_info = debugfs_create_file("survey_info", 0444, p2p0_dir, private_data, &p2p0_survey_info_fops);
1118 if (!p2p0_survey_info)
1121 p2p0_p2p_info = debugfs_create_file("p2p_info", 0444, p2p0_dir, private_data, &p2p_info_fops);
1125 p2p0_ht_info = debugfs_create_file("ht_info", 0444, p2p0_dir, private_data, &p2p0_ht_info_fops);
1132 debugfs_remove_recursive(p2p0_dir);
1137 void exrnx_debugfs_sruvey_info_tbl_init(void *private_data)
1139 struct ecrnx_hw *ecrnx_hw = (struct ecrnx_hw*)private_data;
1140 INIT_LIST_HEAD(&ecrnx_hw->debugfs_survey_info_tbl_ptr);
1143 int ecrnx_debugfs_init(void *private_data)
1145 ecrnx_debugfs_info_init(private_data);
1146 ecrnx_debugfs_hw_init(private_data);
1147 ecrnx_debugfs_wlan0_init(private_data);
1148 ecrnx_debugfs_ap0_init(private_data);
1149 ecrnx_debugfs_p2p0_init(private_data);
1150 exrnx_debugfs_sruvey_info_tbl_init(private_data);
1152 memset(&debugfs_info, 0, sizeof(debugfs_info_t));
1153 init_waitqueue_head(&debugfs_resp.rxdataq);
1157 #ifdef CONFIG_ECRNX_ESWIN_USB
1158 extern struct ring_buffer buf_handle;
1161 void ecrnx_debugfs_exit(void)
1163 if (ecr6600u_dir != NULL)
1164 debugfs_remove_recursive(ecr6600u_dir);
1165 #ifdef CONFIG_ECRNX_ESWIN_USB
1166 ring_buffer_deinit(&buf_handle);