0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "common.h"
0018
0019 static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
0020 size_t count, loff_t *ppos)
0021 {
0022 struct ath_hw *ah = file->private_data;
0023 u32 len = 0, size = 6000;
0024 char *buf;
0025 size_t retval;
0026
0027 buf = kzalloc(size, GFP_KERNEL);
0028 if (buf == NULL)
0029 return -ENOMEM;
0030
0031 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
0032
0033 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0034 kfree(buf);
0035
0036 return retval;
0037 }
0038
0039 static const struct file_operations fops_modal_eeprom = {
0040 .read = read_file_modal_eeprom,
0041 .open = simple_open,
0042 .owner = THIS_MODULE,
0043 .llseek = default_llseek,
0044 };
0045
0046
0047 void ath9k_cmn_debug_modal_eeprom(struct dentry *debugfs_phy,
0048 struct ath_hw *ah)
0049 {
0050 debugfs_create_file("modal_eeprom", 0400, debugfs_phy, ah,
0051 &fops_modal_eeprom);
0052 }
0053 EXPORT_SYMBOL(ath9k_cmn_debug_modal_eeprom);
0054
0055 static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
0056 size_t count, loff_t *ppos)
0057 {
0058 struct ath_hw *ah = file->private_data;
0059 u32 len = 0, size = 1500;
0060 ssize_t retval = 0;
0061 char *buf;
0062
0063 buf = kzalloc(size, GFP_KERNEL);
0064 if (!buf)
0065 return -ENOMEM;
0066
0067 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
0068
0069 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0070 kfree(buf);
0071
0072 return retval;
0073 }
0074
0075 static const struct file_operations fops_base_eeprom = {
0076 .read = read_file_base_eeprom,
0077 .open = simple_open,
0078 .owner = THIS_MODULE,
0079 .llseek = default_llseek,
0080 };
0081
0082 void ath9k_cmn_debug_base_eeprom(struct dentry *debugfs_phy,
0083 struct ath_hw *ah)
0084 {
0085 debugfs_create_file("base_eeprom", 0400, debugfs_phy, ah,
0086 &fops_base_eeprom);
0087 }
0088 EXPORT_SYMBOL(ath9k_cmn_debug_base_eeprom);
0089
0090 void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
0091 struct ath_rx_status *rs)
0092 {
0093 #define RX_PHY_ERR_INC(c) rxstats->phy_err_stats[c]++
0094 #define RX_CMN_STAT_INC(c) (rxstats->c++)
0095
0096 RX_CMN_STAT_INC(rx_pkts_all);
0097 rxstats->rx_bytes_all += rs->rs_datalen;
0098
0099 if (rs->rs_status & ATH9K_RXERR_CRC)
0100 RX_CMN_STAT_INC(crc_err);
0101 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
0102 RX_CMN_STAT_INC(decrypt_crc_err);
0103 if (rs->rs_status & ATH9K_RXERR_MIC)
0104 RX_CMN_STAT_INC(mic_err);
0105 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
0106 RX_CMN_STAT_INC(pre_delim_crc_err);
0107 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
0108 RX_CMN_STAT_INC(post_delim_crc_err);
0109 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
0110 RX_CMN_STAT_INC(decrypt_busy_err);
0111
0112 if (rs->rs_status & ATH9K_RXERR_PHY) {
0113 RX_CMN_STAT_INC(phy_err);
0114 if (rs->rs_phyerr < ATH9K_PHYERR_MAX)
0115 RX_PHY_ERR_INC(rs->rs_phyerr);
0116 }
0117
0118 #undef RX_CMN_STAT_INC
0119 #undef RX_PHY_ERR_INC
0120 }
0121 EXPORT_SYMBOL(ath9k_cmn_debug_stat_rx);
0122
0123 static ssize_t read_file_recv(struct file *file, char __user *user_buf,
0124 size_t count, loff_t *ppos)
0125 {
0126 #define RXS_ERR(s, e) \
0127 do { \
0128 len += scnprintf(buf + len, size - len, \
0129 "%18s : %10u\n", s, \
0130 rxstats->e); \
0131 } while (0)
0132
0133 struct ath_rx_stats *rxstats = file->private_data;
0134 char *buf;
0135 unsigned int len = 0, size = 1600;
0136 ssize_t retval = 0;
0137
0138 buf = kzalloc(size, GFP_KERNEL);
0139 if (buf == NULL)
0140 return -ENOMEM;
0141
0142 RXS_ERR("PKTS-ALL", rx_pkts_all);
0143 RXS_ERR("BYTES-ALL", rx_bytes_all);
0144 RXS_ERR("BEACONS", rx_beacons);
0145 RXS_ERR("FRAGS", rx_frags);
0146 RXS_ERR("SPECTRAL", rx_spectral);
0147 RXS_ERR("SPECTRAL SMPL GOOD", rx_spectral_sample_good);
0148 RXS_ERR("SPECTRAL SMPL ERR", rx_spectral_sample_err);
0149
0150 RXS_ERR("CRC ERR", crc_err);
0151 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
0152 RXS_ERR("PHY ERR", phy_err);
0153 RXS_ERR("MIC ERR", mic_err);
0154 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
0155 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
0156 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
0157 RXS_ERR("LENGTH-ERR", rx_len_err);
0158 RXS_ERR("OOM-ERR", rx_oom_err);
0159 RXS_ERR("RATE-ERR", rx_rate_err);
0160 RXS_ERR("TOO-MANY-FRAGS", rx_too_many_frags_err);
0161
0162 if (len > size)
0163 len = size;
0164
0165 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0166 kfree(buf);
0167
0168 return retval;
0169
0170 #undef RXS_ERR
0171 }
0172
0173 static const struct file_operations fops_recv = {
0174 .read = read_file_recv,
0175 .open = simple_open,
0176 .owner = THIS_MODULE,
0177 .llseek = default_llseek,
0178 };
0179
0180 void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
0181 struct ath_rx_stats *rxstats)
0182 {
0183 debugfs_create_file("recv", 0400, debugfs_phy, rxstats, &fops_recv);
0184 }
0185 EXPORT_SYMBOL(ath9k_cmn_debug_recv);
0186
0187 static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
0188 size_t count, loff_t *ppos)
0189 {
0190 #define PHY_ERR(s, p) \
0191 len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
0192 rxstats->phy_err_stats[p])
0193
0194 struct ath_rx_stats *rxstats = file->private_data;
0195 char *buf;
0196 unsigned int len = 0, size = 1600;
0197 ssize_t retval = 0;
0198
0199 buf = kzalloc(size, GFP_KERNEL);
0200 if (buf == NULL)
0201 return -ENOMEM;
0202
0203 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
0204 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
0205 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY);
0206 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE);
0207 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH);
0208 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR);
0209 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE);
0210 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR);
0211
0212 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING);
0213 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
0214 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
0215 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
0216 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP);
0217 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE);
0218 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART);
0219
0220 PHY_ERR("CCK-BLOCKER ERR", ATH9K_PHYERR_CCK_BLOCKER);
0221 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING);
0222 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC);
0223 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
0224 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
0225 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP);
0226 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE);
0227 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART);
0228
0229 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR);
0230 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
0231 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
0232 PHY_ERR("HT-ZLF ERR", ATH9K_PHYERR_HT_ZLF);
0233
0234 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT);
0235 PHY_ERR("GREEN-FIELD ERR", ATH9K_PHYERR_GREEN_FIELD);
0236 PHY_ERR("SPECTRAL ERR", ATH9K_PHYERR_SPECTRAL);
0237
0238 if (len > size)
0239 len = size;
0240
0241 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
0242 kfree(buf);
0243
0244 return retval;
0245
0246 #undef PHY_ERR
0247 }
0248
0249 static const struct file_operations fops_phy_err = {
0250 .read = read_file_phy_err,
0251 .open = simple_open,
0252 .owner = THIS_MODULE,
0253 .llseek = default_llseek,
0254 };
0255
0256 void ath9k_cmn_debug_phy_err(struct dentry *debugfs_phy,
0257 struct ath_rx_stats *rxstats)
0258 {
0259 debugfs_create_file("phy_err", 0400, debugfs_phy, rxstats,
0260 &fops_phy_err);
0261 }
0262 EXPORT_SYMBOL(ath9k_cmn_debug_phy_err);