diff options
author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-02-06 09:02:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-08 01:52:39 -0500 |
commit | bf7c781d576823e5d71f40585aeeac430a1845c8 (patch) | |
tree | d35c26d3837bea5e1b605567e98d3163218e41d5 /drivers/net/ethernet | |
parent | 797ff0f573184778771b6d1186eca72f7e3adb4d (diff) |
cxgb4: Add support to dump mailbox content in debugfs
Adds support to dump the current contents of mailbox and the driver which owns
it.
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 85 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_values.h | 5 |
3 files changed, 91 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 5a462730bdbe..83e29320a945 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include "cxgb4.h" | 41 | #include "cxgb4.h" |
42 | #include "t4_regs.h" | 42 | #include "t4_regs.h" |
43 | #include "t4_values.h" | ||
43 | #include "t4fw_api.h" | 44 | #include "t4fw_api.h" |
44 | #include "cxgb4_debugfs.h" | 45 | #include "cxgb4_debugfs.h" |
45 | #include "clip_tbl.h" | 46 | #include "clip_tbl.h" |
@@ -920,6 +921,82 @@ static const struct file_operations devlog_fops = { | |||
920 | .release = seq_release_private | 921 | .release = seq_release_private |
921 | }; | 922 | }; |
922 | 923 | ||
924 | static int mbox_show(struct seq_file *seq, void *v) | ||
925 | { | ||
926 | static const char * const owner[] = { "none", "FW", "driver", | ||
927 | "unknown" }; | ||
928 | |||
929 | int i; | ||
930 | unsigned int mbox = (uintptr_t)seq->private & 7; | ||
931 | struct adapter *adap = seq->private - mbox; | ||
932 | void __iomem *addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A); | ||
933 | unsigned int ctrl_reg = (is_t4(adap->params.chip) | ||
934 | ? CIM_PF_MAILBOX_CTRL_A | ||
935 | : CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A); | ||
936 | void __iomem *ctrl = adap->regs + PF_REG(mbox, ctrl_reg); | ||
937 | |||
938 | i = MBOWNER_G(readl(ctrl)); | ||
939 | seq_printf(seq, "mailbox owned by %s\n\n", owner[i]); | ||
940 | |||
941 | for (i = 0; i < MBOX_LEN; i += 8) | ||
942 | seq_printf(seq, "%016llx\n", | ||
943 | (unsigned long long)readq(addr + i)); | ||
944 | return 0; | ||
945 | } | ||
946 | |||
947 | static int mbox_open(struct inode *inode, struct file *file) | ||
948 | { | ||
949 | return single_open(file, mbox_show, inode->i_private); | ||
950 | } | ||
951 | |||
952 | static ssize_t mbox_write(struct file *file, const char __user *buf, | ||
953 | size_t count, loff_t *pos) | ||
954 | { | ||
955 | int i; | ||
956 | char c = '\n', s[256]; | ||
957 | unsigned long long data[8]; | ||
958 | const struct inode *ino; | ||
959 | unsigned int mbox; | ||
960 | struct adapter *adap; | ||
961 | void __iomem *addr; | ||
962 | void __iomem *ctrl; | ||
963 | |||
964 | if (count > sizeof(s) - 1 || !count) | ||
965 | return -EINVAL; | ||
966 | if (copy_from_user(s, buf, count)) | ||
967 | return -EFAULT; | ||
968 | s[count] = '\0'; | ||
969 | |||
970 | if (sscanf(s, "%llx %llx %llx %llx %llx %llx %llx %llx%c", &data[0], | ||
971 | &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], | ||
972 | &data[7], &c) < 8 || c != '\n') | ||
973 | return -EINVAL; | ||
974 | |||
975 | ino = FILE_DATA(file); | ||
976 | mbox = (uintptr_t)ino->i_private & 7; | ||
977 | adap = ino->i_private - mbox; | ||
978 | addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A); | ||
979 | ctrl = addr + MBOX_LEN; | ||
980 | |||
981 | if (MBOWNER_G(readl(ctrl)) != X_MBOWNER_PL) | ||
982 | return -EBUSY; | ||
983 | |||
984 | for (i = 0; i < 8; i++) | ||
985 | writeq(data[i], addr + 8 * i); | ||
986 | |||
987 | writel(MBMSGVALID_F | MBOWNER_V(X_MBOWNER_FW), ctrl); | ||
988 | return count; | ||
989 | } | ||
990 | |||
991 | static const struct file_operations mbox_debugfs_fops = { | ||
992 | .owner = THIS_MODULE, | ||
993 | .open = mbox_open, | ||
994 | .read = seq_read, | ||
995 | .llseek = seq_lseek, | ||
996 | .release = single_release, | ||
997 | .write = mbox_write | ||
998 | }; | ||
999 | |||
923 | static ssize_t flash_read(struct file *file, char __user *buf, size_t count, | 1000 | static ssize_t flash_read(struct file *file, char __user *buf, size_t count, |
924 | loff_t *ppos) | 1001 | loff_t *ppos) |
925 | { | 1002 | { |
@@ -1881,6 +1958,14 @@ int t4_setup_debugfs(struct adapter *adap) | |||
1881 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, | 1958 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, |
1882 | { "clk", &clk_debugfs_fops, S_IRUSR, 0 }, | 1959 | { "clk", &clk_debugfs_fops, S_IRUSR, 0 }, |
1883 | { "devlog", &devlog_fops, S_IRUSR, 0 }, | 1960 | { "devlog", &devlog_fops, S_IRUSR, 0 }, |
1961 | { "mbox0", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 0 }, | ||
1962 | { "mbox1", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 1 }, | ||
1963 | { "mbox2", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 2 }, | ||
1964 | { "mbox3", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 3 }, | ||
1965 | { "mbox4", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 4 }, | ||
1966 | { "mbox5", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 5 }, | ||
1967 | { "mbox6", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 6 }, | ||
1968 | { "mbox7", &mbox_debugfs_fops, S_IRUSR | S_IWUSR, 7 }, | ||
1884 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, | 1969 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, |
1885 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, | 1970 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, |
1886 | { "rss", &rss_debugfs_fops, S_IRUSR, 0 }, | 1971 | { "rss", &rss_debugfs_fops, S_IRUSR, 0 }, |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h index 91e0ea1954f0..3f18d5c5e7f0 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | |||
@@ -947,6 +947,7 @@ | |||
947 | 947 | ||
948 | /* registers for module CIM */ | 948 | /* registers for module CIM */ |
949 | #define CIM_BOOT_CFG_A 0x7b00 | 949 | #define CIM_BOOT_CFG_A 0x7b00 |
950 | #define CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A 0x290 | ||
950 | 951 | ||
951 | #define BOOTADDR_M 0xffffff00U | 952 | #define BOOTADDR_M 0xffffff00U |
952 | 953 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_values.h b/drivers/net/ethernet/chelsio/cxgb4/t4_values.h index 997ec87470c7..19b2dcf6acde 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_values.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_values.h | |||
@@ -79,6 +79,11 @@ | |||
79 | #define SGE_UDB_GTS 20 | 79 | #define SGE_UDB_GTS 20 |
80 | #define SGE_UDB_WCDOORBELL 64 | 80 | #define SGE_UDB_WCDOORBELL 64 |
81 | 81 | ||
82 | /* CIM register field values. | ||
83 | */ | ||
84 | #define X_MBOWNER_FW 1 | ||
85 | #define X_MBOWNER_PL 2 | ||
86 | |||
82 | /* PCI-E definitions */ | 87 | /* PCI-E definitions */ |
83 | #define WINDOW_SHIFT_X 10 | 88 | #define WINDOW_SHIFT_X 10 |
84 | #define PCIEOFST_SHIFT_X 10 | 89 | #define PCIEOFST_SHIFT_X 10 |