|
40 | 40 |
|
41 | 41 | #include "cxgb4.h" |
42 | 42 | #include "t4_regs.h" |
| 43 | +#include "t4_values.h" |
43 | 44 | #include "t4fw_api.h" |
44 | 45 | #include "cxgb4_debugfs.h" |
45 | 46 | #include "clip_tbl.h" |
@@ -920,6 +921,82 @@ static const struct file_operations devlog_fops = { |
920 | 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 | 1000 | static ssize_t flash_read(struct file *file, char __user *buf, size_t count, |
924 | 1001 | loff_t *ppos) |
925 | 1002 | { |
@@ -1881,6 +1958,14 @@ int t4_setup_debugfs(struct adapter *adap) |
1881 | 1958 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, |
1882 | 1959 | { "clk", &clk_debugfs_fops, S_IRUSR, 0 }, |
1883 | 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 | 1969 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, |
1885 | 1970 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, |
1886 | 1971 | { "rss", &rss_debugfs_fops, S_IRUSR, 0 }, |
|
0 commit comments