debug.c (e8091281f588812b128e102307e13acd9e917a5b) | debug.c (4b28a80dd6713c404f4f0084007456b769aba553) |
---|---|
1/* 2 * Copyright (c) 2004-2011 Atheros Communications Inc. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --- 952 unchanged lines hidden (view full) --- 961static const struct file_operations fops_diag_reg_write = { 962 .read = ath6kl_regwrite_read, 963 .write = ath6kl_regwrite_write, 964 .open = ath6kl_debugfs_open, 965 .owner = THIS_MODULE, 966 .llseek = default_llseek, 967}; 968 | 1/* 2 * Copyright (c) 2004-2011 Atheros Communications Inc. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --- 952 unchanged lines hidden (view full) --- 961static const struct file_operations fops_diag_reg_write = { 962 .read = ath6kl_regwrite_read, 963 .write = ath6kl_regwrite_write, 964 .open = ath6kl_debugfs_open, 965 .owner = THIS_MODULE, 966 .llseek = default_llseek, 967}; 968 |
969int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, 970 size_t len) 971{ 972 const struct wmi_target_roam_tbl *tbl; 973 u16 num_entries; 974 975 if (len < sizeof(*tbl)) 976 return -EINVAL; 977 978 tbl = (const struct wmi_target_roam_tbl *) buf; 979 num_entries = le16_to_cpu(tbl->num_entries); 980 if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) > 981 len) 982 return -EINVAL; 983 984 if (ar->debug.roam_tbl == NULL || 985 ar->debug.roam_tbl_len < (unsigned int) len) { 986 kfree(ar->debug.roam_tbl); 987 ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC); 988 if (ar->debug.roam_tbl == NULL) 989 return -ENOMEM; 990 } 991 992 memcpy(ar->debug.roam_tbl, buf, len); 993 ar->debug.roam_tbl_len = len; 994 995 if (test_bit(ROAM_TBL_PEND, &ar->flag)) { 996 clear_bit(ROAM_TBL_PEND, &ar->flag); 997 wake_up(&ar->event_wq); 998 } 999 1000 return 0; 1001} 1002 1003static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf, 1004 size_t count, loff_t *ppos) 1005{ 1006 struct ath6kl *ar = file->private_data; 1007 int ret; 1008 long left; 1009 struct wmi_target_roam_tbl *tbl; 1010 u16 num_entries, i; 1011 char *buf; 1012 unsigned int len, buf_len; 1013 ssize_t ret_cnt; 1014 1015 if (down_interruptible(&ar->sem)) 1016 return -EBUSY; 1017 1018 set_bit(ROAM_TBL_PEND, &ar->flag); 1019 1020 ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi); 1021 if (ret) { 1022 up(&ar->sem); 1023 return ret; 1024 } 1025 1026 left = wait_event_interruptible_timeout( 1027 ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT); 1028 up(&ar->sem); 1029 1030 if (left <= 0) 1031 return -ETIMEDOUT; 1032 1033 if (ar->debug.roam_tbl == NULL) 1034 return -ENOMEM; 1035 1036 tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl; 1037 num_entries = le16_to_cpu(tbl->num_entries); 1038 1039 buf_len = 100 + num_entries * 100; 1040 buf = kzalloc(buf_len, GFP_KERNEL); 1041 if (buf == NULL) 1042 return -ENOMEM; 1043 len = 0; 1044 len += scnprintf(buf + len, buf_len - len, 1045 "roam_mode=%u\n\n" 1046 "# roam_util bssid rssi rssidt last_rssi util bias\n", 1047 le16_to_cpu(tbl->roam_mode)); 1048 1049 for (i = 0; i < num_entries; i++) { 1050 struct wmi_bss_roam_info *info = &tbl->info[i]; 1051 len += scnprintf(buf + len, buf_len - len, 1052 "%d %pM %d %d %d %d %d\n", 1053 a_sle32_to_cpu(info->roam_util), info->bssid, 1054 info->rssi, info->rssidt, info->last_rssi, 1055 info->util, info->bias); 1056 } 1057 1058 if (len > buf_len) 1059 len = buf_len; 1060 1061 ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1062 1063 kfree(buf); 1064 return ret_cnt; 1065} 1066 1067static const struct file_operations fops_roam_table = { 1068 .read = ath6kl_roam_table_read, 1069 .open = ath6kl_debugfs_open, 1070 .owner = THIS_MODULE, 1071 .llseek = default_llseek, 1072}; 1073 |
|
969int ath6kl_debug_init(struct ath6kl *ar) 970{ 971 ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); 972 if (ar->debug.fwlog_buf.buf == NULL) 973 return -ENOMEM; 974 975 ar->debug.fwlog_tmp = kmalloc(ATH6KL_FWLOG_SLOT_SIZE, GFP_KERNEL); 976 if (ar->debug.fwlog_tmp == NULL) { --- 42 unchanged lines hidden (view full) --- 1019 ar->debugfs_phy, ar, &fops_lrssi_roam_threshold); 1020 1021 debugfs_create_file("reg_write", S_IRUSR | S_IWUSR, 1022 ar->debugfs_phy, ar, &fops_diag_reg_write); 1023 1024 debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar, 1025 &fops_war_stats); 1026 | 1074int ath6kl_debug_init(struct ath6kl *ar) 1075{ 1076 ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); 1077 if (ar->debug.fwlog_buf.buf == NULL) 1078 return -ENOMEM; 1079 1080 ar->debug.fwlog_tmp = kmalloc(ATH6KL_FWLOG_SLOT_SIZE, GFP_KERNEL); 1081 if (ar->debug.fwlog_tmp == NULL) { --- 42 unchanged lines hidden (view full) --- 1124 ar->debugfs_phy, ar, &fops_lrssi_roam_threshold); 1125 1126 debugfs_create_file("reg_write", S_IRUSR | S_IWUSR, 1127 ar->debugfs_phy, ar, &fops_diag_reg_write); 1128 1129 debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar, 1130 &fops_war_stats); 1131 |
1132 debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar, 1133 &fops_roam_table); 1134 |
|
1027 return 0; 1028} 1029 1030void ath6kl_debug_cleanup(struct ath6kl *ar) 1031{ 1032 vfree(ar->debug.fwlog_buf.buf); 1033 kfree(ar->debug.fwlog_tmp); | 1135 return 0; 1136} 1137 1138void ath6kl_debug_cleanup(struct ath6kl *ar) 1139{ 1140 vfree(ar->debug.fwlog_buf.buf); 1141 kfree(ar->debug.fwlog_tmp); |
1142 kfree(ar->debug.roam_tbl); |
|
1034} 1035 1036#endif | 1143} 1144 1145#endif |