Oleksij Rempel | f2c3c95 | 2014-05-11 10:04:31 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008-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 |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include "common.h" |
| 18 | |
| 19 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
| 20 | size_t count, loff_t *ppos) |
| 21 | { |
| 22 | struct ath_hw *ah = file->private_data; |
| 23 | u32 len = 0, size = 6000; |
| 24 | char *buf; |
| 25 | size_t retval; |
| 26 | |
| 27 | buf = kzalloc(size, GFP_KERNEL); |
| 28 | if (buf == NULL) |
| 29 | return -ENOMEM; |
| 30 | |
| 31 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); |
| 32 | |
| 33 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 34 | kfree(buf); |
| 35 | |
| 36 | return retval; |
| 37 | } |
| 38 | |
| 39 | static const struct file_operations fops_modal_eeprom = { |
| 40 | .read = read_file_modal_eeprom, |
| 41 | .open = simple_open, |
| 42 | .owner = THIS_MODULE, |
| 43 | .llseek = default_llseek, |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | void ath9k_cmn_debug_modal_eeprom(struct dentry *debugfs_phy, |
| 48 | struct ath_hw *ah) |
| 49 | { |
| 50 | debugfs_create_file("modal_eeprom", S_IRUSR, debugfs_phy, ah, |
| 51 | &fops_modal_eeprom); |
| 52 | } |
| 53 | EXPORT_SYMBOL(ath9k_cmn_debug_modal_eeprom); |
Oleksij Rempel | 29bf801 | 2014-05-11 10:04:33 +0200 | [diff] [blame] | 54 | |
| 55 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
| 56 | size_t count, loff_t *ppos) |
| 57 | { |
| 58 | struct ath_hw *ah = file->private_data; |
| 59 | u32 len = 0, size = 1500; |
| 60 | ssize_t retval = 0; |
| 61 | char *buf; |
| 62 | |
| 63 | buf = kzalloc(size, GFP_KERNEL); |
| 64 | if (!buf) |
| 65 | return -ENOMEM; |
| 66 | |
| 67 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); |
| 68 | |
| 69 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 70 | kfree(buf); |
| 71 | |
| 72 | return retval; |
| 73 | } |
| 74 | |
| 75 | static const struct file_operations fops_base_eeprom = { |
| 76 | .read = read_file_base_eeprom, |
| 77 | .open = simple_open, |
| 78 | .owner = THIS_MODULE, |
| 79 | .llseek = default_llseek, |
| 80 | }; |
| 81 | |
| 82 | void ath9k_cmn_debug_base_eeprom(struct dentry *debugfs_phy, |
| 83 | struct ath_hw *ah) |
| 84 | { |
| 85 | debugfs_create_file("base_eeprom", S_IRUSR, debugfs_phy, ah, |
| 86 | &fops_base_eeprom); |
| 87 | } |
| 88 | EXPORT_SYMBOL(ath9k_cmn_debug_base_eeprom); |
Oleksij Rempel | b5a0c86 | 2014-05-11 10:04:36 +0200 | [diff] [blame^] | 89 | |
| 90 | void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats, |
| 91 | struct ath_rx_status *rs) |
| 92 | { |
| 93 | #define RX_PHY_ERR_INC(c) rxstats->phy_err_stats[c]++ |
| 94 | #define RX_CMN_STAT_INC(c) (rxstats->c++) |
| 95 | |
| 96 | RX_CMN_STAT_INC(rx_pkts_all); |
| 97 | rxstats->rx_bytes_all += rs->rs_datalen; |
| 98 | |
| 99 | if (rs->rs_status & ATH9K_RXERR_CRC) |
| 100 | RX_CMN_STAT_INC(crc_err); |
| 101 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
| 102 | RX_CMN_STAT_INC(decrypt_crc_err); |
| 103 | if (rs->rs_status & ATH9K_RXERR_MIC) |
| 104 | RX_CMN_STAT_INC(mic_err); |
| 105 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
| 106 | RX_CMN_STAT_INC(pre_delim_crc_err); |
| 107 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
| 108 | RX_CMN_STAT_INC(post_delim_crc_err); |
| 109 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
| 110 | RX_CMN_STAT_INC(decrypt_busy_err); |
| 111 | |
| 112 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
| 113 | RX_CMN_STAT_INC(phy_err); |
| 114 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
| 115 | RX_PHY_ERR_INC(rs->rs_phyerr); |
| 116 | } |
| 117 | |
| 118 | #undef RX_CMN_STAT_INC |
| 119 | #undef RX_PHY_ERR_INC |
| 120 | } |
| 121 | EXPORT_SYMBOL(ath9k_cmn_debug_stat_rx); |