aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-trans.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2011-08-26 02:11:08 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-29 15:30:27 -0400
commit16db88ba51d669ef63c58990771a47208913152c (patch)
tree9382f559cc8a20bdfaf84be0d47395c82e85d560 /drivers/net/wireless/iwlwifi/iwl-trans.c
parent72012474b01e2f2d433e4253505f5dcfb3345d17 (diff)
iwlagn: move dump_csr and dump_fh to transport layer
These are transport layer related. Move also the corresponding debugfs handlers. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-trans.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.c182
1 files changed, 182 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index 73883fe1c2d1..e55636e1deaf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -1324,6 +1324,14 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
1324 .llseek = generic_file_llseek, \ 1324 .llseek = generic_file_llseek, \
1325}; 1325};
1326 1326
1327#define DEBUGFS_WRITE_FILE_OPS(name) \
1328 DEBUGFS_WRITE_FUNC(name); \
1329static const struct file_operations iwl_dbgfs_##name##_ops = { \
1330 .write = iwl_dbgfs_##name##_write, \
1331 .open = iwl_dbgfs_open_file_generic, \
1332 .llseek = generic_file_llseek, \
1333};
1334
1327#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ 1335#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
1328 DEBUGFS_READ_FUNC(name); \ 1336 DEBUGFS_READ_FUNC(name); \
1329 DEBUGFS_WRITE_FUNC(name); \ 1337 DEBUGFS_WRITE_FUNC(name); \
@@ -1635,11 +1643,183 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
1635 return count; 1643 return count;
1636} 1644}
1637 1645
1646static const char *get_csr_string(int cmd)
1647{
1648 switch (cmd) {
1649 IWL_CMD(CSR_HW_IF_CONFIG_REG);
1650 IWL_CMD(CSR_INT_COALESCING);
1651 IWL_CMD(CSR_INT);
1652 IWL_CMD(CSR_INT_MASK);
1653 IWL_CMD(CSR_FH_INT_STATUS);
1654 IWL_CMD(CSR_GPIO_IN);
1655 IWL_CMD(CSR_RESET);
1656 IWL_CMD(CSR_GP_CNTRL);
1657 IWL_CMD(CSR_HW_REV);
1658 IWL_CMD(CSR_EEPROM_REG);
1659 IWL_CMD(CSR_EEPROM_GP);
1660 IWL_CMD(CSR_OTP_GP_REG);
1661 IWL_CMD(CSR_GIO_REG);
1662 IWL_CMD(CSR_GP_UCODE_REG);
1663 IWL_CMD(CSR_GP_DRIVER_REG);
1664 IWL_CMD(CSR_UCODE_DRV_GP1);
1665 IWL_CMD(CSR_UCODE_DRV_GP2);
1666 IWL_CMD(CSR_LED_REG);
1667 IWL_CMD(CSR_DRAM_INT_TBL_REG);
1668 IWL_CMD(CSR_GIO_CHICKEN_BITS);
1669 IWL_CMD(CSR_ANA_PLL_CFG);
1670 IWL_CMD(CSR_HW_REV_WA_REG);
1671 IWL_CMD(CSR_DBG_HPET_MEM_REG);
1672 default:
1673 return "UNKNOWN";
1674 }
1675}
1676
1677void iwl_dump_csr(struct iwl_trans *trans)
1678{
1679 int i;
1680 static const u32 csr_tbl[] = {
1681 CSR_HW_IF_CONFIG_REG,
1682 CSR_INT_COALESCING,
1683 CSR_INT,
1684 CSR_INT_MASK,
1685 CSR_FH_INT_STATUS,
1686 CSR_GPIO_IN,
1687 CSR_RESET,
1688 CSR_GP_CNTRL,
1689 CSR_HW_REV,
1690 CSR_EEPROM_REG,
1691 CSR_EEPROM_GP,
1692 CSR_OTP_GP_REG,
1693 CSR_GIO_REG,
1694 CSR_GP_UCODE_REG,
1695 CSR_GP_DRIVER_REG,
1696 CSR_UCODE_DRV_GP1,
1697 CSR_UCODE_DRV_GP2,
1698 CSR_LED_REG,
1699 CSR_DRAM_INT_TBL_REG,
1700 CSR_GIO_CHICKEN_BITS,
1701 CSR_ANA_PLL_CFG,
1702 CSR_HW_REV_WA_REG,
1703 CSR_DBG_HPET_MEM_REG
1704 };
1705 IWL_ERR(trans, "CSR values:\n");
1706 IWL_ERR(trans, "(2nd byte of CSR_INT_COALESCING is "
1707 "CSR_INT_PERIODIC_REG)\n");
1708 for (i = 0; i < ARRAY_SIZE(csr_tbl); i++) {
1709 IWL_ERR(trans, " %25s: 0X%08x\n",
1710 get_csr_string(csr_tbl[i]),
1711 iwl_read32(priv(trans), csr_tbl[i]));
1712 }
1713}
1714
1715static ssize_t iwl_dbgfs_csr_write(struct file *file,
1716 const char __user *user_buf,
1717 size_t count, loff_t *ppos)
1718{
1719 struct iwl_trans *trans = file->private_data;
1720 char buf[8];
1721 int buf_size;
1722 int csr;
1723
1724 memset(buf, 0, sizeof(buf));
1725 buf_size = min(count, sizeof(buf) - 1);
1726 if (copy_from_user(buf, user_buf, buf_size))
1727 return -EFAULT;
1728 if (sscanf(buf, "%d", &csr) != 1)
1729 return -EFAULT;
1730
1731 iwl_dump_csr(trans);
1732
1733 return count;
1734}
1735
1736static const char *get_fh_string(int cmd)
1737{
1738 switch (cmd) {
1739 IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG);
1740 IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG);
1741 IWL_CMD(FH_RSCSR_CHNL0_WPTR);
1742 IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG);
1743 IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG);
1744 IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG);
1745 IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV);
1746 IWL_CMD(FH_TSSR_TX_STATUS_REG);
1747 IWL_CMD(FH_TSSR_TX_ERROR_REG);
1748 default:
1749 return "UNKNOWN";
1750 }
1751}
1752
1753int iwl_dump_fh(struct iwl_trans *trans, char **buf, bool display)
1754{
1755 int i;
1756#ifdef CONFIG_IWLWIFI_DEBUG
1757 int pos = 0;
1758 size_t bufsz = 0;
1759#endif
1760 static const u32 fh_tbl[] = {
1761 FH_RSCSR_CHNL0_STTS_WPTR_REG,
1762 FH_RSCSR_CHNL0_RBDCB_BASE_REG,
1763 FH_RSCSR_CHNL0_WPTR,
1764 FH_MEM_RCSR_CHNL0_CONFIG_REG,
1765 FH_MEM_RSSR_SHARED_CTRL_REG,
1766 FH_MEM_RSSR_RX_STATUS_REG,
1767 FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV,
1768 FH_TSSR_TX_STATUS_REG,
1769 FH_TSSR_TX_ERROR_REG
1770 };
1771#ifdef CONFIG_IWLWIFI_DEBUG
1772 if (display) {
1773 bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40;
1774 *buf = kmalloc(bufsz, GFP_KERNEL);
1775 if (!*buf)
1776 return -ENOMEM;
1777 pos += scnprintf(*buf + pos, bufsz - pos,
1778 "FH register values:\n");
1779 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) {
1780 pos += scnprintf(*buf + pos, bufsz - pos,
1781 " %34s: 0X%08x\n",
1782 get_fh_string(fh_tbl[i]),
1783 iwl_read_direct32(priv(trans), fh_tbl[i]));
1784 }
1785 return pos;
1786 }
1787#endif
1788 IWL_ERR(trans, "FH register values:\n");
1789 for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) {
1790 IWL_ERR(trans, " %34s: 0X%08x\n",
1791 get_fh_string(fh_tbl[i]),
1792 iwl_read_direct32(priv(trans), fh_tbl[i]));
1793 }
1794 return 0;
1795}
1796
1797static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
1798 char __user *user_buf,
1799 size_t count, loff_t *ppos)
1800{
1801 struct iwl_trans *trans = file->private_data;
1802 char *buf;
1803 int pos = 0;
1804 ssize_t ret = -EFAULT;
1805
1806 ret = pos = iwl_dump_fh(trans, &buf, true);
1807 if (buf) {
1808 ret = simple_read_from_buffer(user_buf,
1809 count, ppos, buf, pos);
1810 kfree(buf);
1811 }
1812
1813 return ret;
1814}
1815
1638DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 1816DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
1639DEBUGFS_READ_WRITE_FILE_OPS(log_event); 1817DEBUGFS_READ_WRITE_FILE_OPS(log_event);
1640DEBUGFS_READ_WRITE_FILE_OPS(interrupt); 1818DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
1819DEBUGFS_READ_FILE_OPS(fh_reg);
1641DEBUGFS_READ_FILE_OPS(rx_queue); 1820DEBUGFS_READ_FILE_OPS(rx_queue);
1642DEBUGFS_READ_FILE_OPS(tx_queue); 1821DEBUGFS_READ_FILE_OPS(tx_queue);
1822DEBUGFS_WRITE_FILE_OPS(csr);
1643 1823
1644/* 1824/*
1645 * Create the debugfs files and directories 1825 * Create the debugfs files and directories
@@ -1653,6 +1833,8 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans,
1653 DEBUGFS_ADD_FILE(tx_queue, dir, S_IRUSR); 1833 DEBUGFS_ADD_FILE(tx_queue, dir, S_IRUSR);
1654 DEBUGFS_ADD_FILE(log_event, dir, S_IWUSR | S_IRUSR); 1834 DEBUGFS_ADD_FILE(log_event, dir, S_IWUSR | S_IRUSR);
1655 DEBUGFS_ADD_FILE(interrupt, dir, S_IWUSR | S_IRUSR); 1835 DEBUGFS_ADD_FILE(interrupt, dir, S_IWUSR | S_IRUSR);
1836 DEBUGFS_ADD_FILE(csr, dir, S_IWUSR);
1837 DEBUGFS_ADD_FILE(fh_reg, dir, S_IRUSR);
1656 return 0; 1838 return 0;
1657} 1839}
1658#else 1840#else