From ee3bdb819eb9b927d0dada93124cb38b1bb5346b Mon Sep 17 00:00:00 2001 From: Luo Jiaxing Date: Mon, 5 Nov 2018 17:55:45 +0800 Subject: [PATCH] scsi: hisi_sas: Add DFX Feature: ITCT create file and add file operations This patch create debugfs file for ITCT and add file operations Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 6b1135424f1a..1216cdba902a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2902,6 +2902,36 @@ static const struct file_operations hisi_sas_debugfs_iost_fops = { .owner = THIS_MODULE, }; +static int hisi_sas_debugfs_itct_show(struct seq_file *s, void *p) +{ + int i, ret; + struct hisi_hba *hisi_hba = s->private; + struct hisi_sas_itct *itct_debugfs = hisi_hba->itct_debugfs; + + for (i = 0; i < HISI_SAS_MAX_ITCT_ENTRIES; i++, itct_debugfs++) { + ret = hisi_sas_show_row_64(s, i, + sizeof(*itct_debugfs), + (u64 *)itct_debugfs); + if (ret) + return ret; + } + + return 0; +} + +static int hisi_sas_debugfs_itct_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, hisi_sas_debugfs_itct_show, inode->i_private); +} + +static const struct file_operations hisi_sas_debugfs_itct_fops = { + .open = hisi_sas_debugfs_itct_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba) { struct dentry *dump_dentry; @@ -2977,6 +3007,16 @@ static void hisi_sas_create_folder_structure(struct hisi_hba *hisi_hba) &hisi_sas_debugfs_iost_fops)) goto fail; + /* Create itct dir and files */ + dentry = debugfs_create_dir("itct", dump_dentry); + if (!dentry) + goto fail; + + if (!debugfs_create_file("itct", 0400, dentry, + hisi_hba, + &hisi_sas_debugfs_itct_fops)) + goto fail; + return; fail: debugfs_remove_recursive(hisi_hba->debugfs_dir); -- GitLab