Commit ba53572b authored by Shivasharan S's avatar Shivasharan S Committed by Martin K. Petersen

scsi: megaraid_sas: Export RAID map through debugfs

Create a debugfs interface for megaraid_sas driver.  Provide interface to
dump driver RAID map in debugfs.
Signed-off-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: default avatarShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent ce88418d
...@@ -3,4 +3,4 @@ obj-$(CONFIG_MEGARAID_MM) += megaraid_mm.o ...@@ -3,4 +3,4 @@ obj-$(CONFIG_MEGARAID_MM) += megaraid_mm.o
obj-$(CONFIG_MEGARAID_MAILBOX) += megaraid_mbox.o obj-$(CONFIG_MEGARAID_MAILBOX) += megaraid_mbox.o
obj-$(CONFIG_MEGARAID_SAS) += megaraid_sas.o obj-$(CONFIG_MEGARAID_SAS) += megaraid_sas.o
megaraid_sas-objs := megaraid_sas_base.o megaraid_sas_fusion.o \ megaraid_sas-objs := megaraid_sas_base.o megaraid_sas_fusion.o \
megaraid_sas_fp.o megaraid_sas_fp.o megaraid_sas_debugfs.o
...@@ -2390,6 +2390,10 @@ struct megasas_instance { ...@@ -2390,6 +2390,10 @@ struct megasas_instance {
u8 task_abort_tmo; u8 task_abort_tmo;
u8 max_reset_tmo; u8 max_reset_tmo;
u8 snapdump_wait_time; u8 snapdump_wait_time;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_root;
struct dentry *raidmap_dump;
#endif
u8 enable_fw_dev_list; u8 enable_fw_dev_list;
}; };
struct MR_LD_VF_MAP { struct MR_LD_VF_MAP {
......
...@@ -188,6 +188,12 @@ static bool support_nvme_encapsulation; ...@@ -188,6 +188,12 @@ static bool support_nvme_encapsulation;
/* define lock for aen poll */ /* define lock for aen poll */
spinlock_t poll_aen_lock; spinlock_t poll_aen_lock;
extern struct dentry *megasas_debugfs_root;
extern void megasas_init_debugfs(void);
extern void megasas_exit_debugfs(void);
extern void megasas_setup_debugfs(struct megasas_instance *instance);
extern void megasas_destroy_debugfs(struct megasas_instance *instance);
void void
megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
u8 alt_status); u8 alt_status);
...@@ -7139,6 +7145,8 @@ static int megasas_probe_one(struct pci_dev *pdev, ...@@ -7139,6 +7145,8 @@ static int megasas_probe_one(struct pci_dev *pdev,
goto fail_start_aen; goto fail_start_aen;
} }
megasas_setup_debugfs(instance);
/* Get current SR-IOV LD/VF affiliation */ /* Get current SR-IOV LD/VF affiliation */
if (instance->requestorId) if (instance->requestorId)
megasas_get_ld_vf_affiliation(instance, 1); megasas_get_ld_vf_affiliation(instance, 1);
...@@ -7609,6 +7617,8 @@ static void megasas_detach_one(struct pci_dev *pdev) ...@@ -7609,6 +7617,8 @@ static void megasas_detach_one(struct pci_dev *pdev)
megasas_free_ctrl_mem(instance); megasas_free_ctrl_mem(instance);
megasas_destroy_debugfs(instance);
scsi_host_put(host); scsi_host_put(host);
pci_disable_device(pdev); pci_disable_device(pdev);
...@@ -8536,6 +8546,8 @@ static int __init megasas_init(void) ...@@ -8536,6 +8546,8 @@ static int __init megasas_init(void)
megasas_mgmt_majorno = rval; megasas_mgmt_majorno = rval;
megasas_init_debugfs();
/* /*
* Register ourselves as PCI hotplug module * Register ourselves as PCI hotplug module
*/ */
...@@ -8595,6 +8607,7 @@ static int __init megasas_init(void) ...@@ -8595,6 +8607,7 @@ static int __init megasas_init(void)
err_dcf_attr_ver: err_dcf_attr_ver:
pci_unregister_driver(&megasas_pci_driver); pci_unregister_driver(&megasas_pci_driver);
err_pcidrv: err_pcidrv:
megasas_exit_debugfs();
unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl"); unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
return rval; return rval;
} }
...@@ -8617,6 +8630,7 @@ static void __exit megasas_exit(void) ...@@ -8617,6 +8630,7 @@ static void __exit megasas_exit(void)
&driver_attr_support_nvme_encapsulation); &driver_attr_support_nvme_encapsulation);
pci_unregister_driver(&megasas_pci_driver); pci_unregister_driver(&megasas_pci_driver);
megasas_exit_debugfs();
unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl"); unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
} }
......
/*
* Linux MegaRAID driver for SAS based RAID controllers
*
* Copyright (c) 2003-2018 LSI Corporation.
* Copyright (c) 2003-2018 Avago Technologies.
* Copyright (c) 2003-2018 Broadcom Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Broadcom Inc.
* Kashyap Desai <kashyap.desai@broadcom.com>
* Sumit Saxena <sumit.saxena@broadcom.com>
* Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
*
* Send feedback to: megaraidlinux.pdl@broadcom.com
*/
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/compat.h>
#include <linux/irq_poll.h>
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include "megaraid_sas_fusion.h"
#include "megaraid_sas.h"
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
struct dentry *megasas_debugfs_root;
static ssize_t
megasas_debugfs_read(struct file *filp, char __user *ubuf, size_t cnt,
loff_t *ppos)
{
struct megasas_debugfs_buffer *debug = filp->private_data;
if (!debug || !debug->buf)
return 0;
return simple_read_from_buffer(ubuf, cnt, ppos, debug->buf, debug->len);
}
static int
megasas_debugfs_raidmap_open(struct inode *inode, struct file *file)
{
struct megasas_instance *instance = inode->i_private;
struct megasas_debugfs_buffer *debug;
struct fusion_context *fusion;
fusion = instance->ctrl_context;
debug = kzalloc(sizeof(struct megasas_debugfs_buffer), GFP_KERNEL);
if (!debug)
return -ENOMEM;
debug->buf = (void *)fusion->ld_drv_map[(instance->map_id & 1)];
debug->len = fusion->drv_map_sz;
file->private_data = debug;
return 0;
}
static int
megasas_debugfs_release(struct inode *inode, struct file *file)
{
struct megasas_debug_buffer *debug = file->private_data;
if (!debug)
return 0;
file->private_data = NULL;
kfree(debug);
return 0;
}
static const struct file_operations megasas_debugfs_raidmap_fops = {
.owner = THIS_MODULE,
.open = megasas_debugfs_raidmap_open,
.read = megasas_debugfs_read,
.release = megasas_debugfs_release,
};
/*
* megasas_init_debugfs : Create debugfs root for megaraid_sas driver
*/
void megasas_init_debugfs(void)
{
megasas_debugfs_root = debugfs_create_dir("megaraid_sas", NULL);
if (!megasas_debugfs_root)
pr_info("Cannot create debugfs root\n");
}
/*
* megasas_exit_debugfs : Remove debugfs root for megaraid_sas driver
*/
void megasas_exit_debugfs(void)
{
debugfs_remove_recursive(megasas_debugfs_root);
}
/*
* megasas_setup_debugfs : Setup debugfs per Fusion adapter
* instance: Soft instance of adapter
*/
void
megasas_setup_debugfs(struct megasas_instance *instance)
{
char name[64];
struct fusion_context *fusion;
fusion = instance->ctrl_context;
if (fusion) {
snprintf(name, sizeof(name),
"scsi_host%d", instance->host->host_no);
if (!instance->debugfs_root) {
instance->debugfs_root =
debugfs_create_dir(name, megasas_debugfs_root);
if (!instance->debugfs_root) {
dev_err(&instance->pdev->dev,
"Cannot create per adapter debugfs directory\n");
return;
}
}
snprintf(name, sizeof(name), "raidmap_dump");
instance->raidmap_dump =
debugfs_create_file(name, S_IRUGO,
instance->debugfs_root, instance,
&megasas_debugfs_raidmap_fops);
if (!instance->raidmap_dump) {
dev_err(&instance->pdev->dev,
"Cannot create raidmap debugfs file\n");
debugfs_remove(instance->debugfs_root);
return;
}
}
}
/*
* megasas_destroy_debugfs : Destroy debugfs per Fusion adapter
* instance: Soft instance of adapter
*/
void megasas_destroy_debugfs(struct megasas_instance *instance)
{
debugfs_remove_recursive(instance->debugfs_root);
}
#else
void megasas_init_debugfs(void)
{
}
void megasas_exit_debugfs(void)
{
}
void megasas_setup_debugfs(struct megasas_instance *instance)
{
}
void megasas_destroy_debugfs(struct megasas_instance *instance)
{
}
#endif /*CONFIG_DEBUG_FS*/
...@@ -1360,6 +1360,11 @@ struct MR_SNAPDUMP_PROPERTIES { ...@@ -1360,6 +1360,11 @@ struct MR_SNAPDUMP_PROPERTIES {
u8 reserved[12]; u8 reserved[12];
}; };
struct megasas_debugfs_buffer {
void *buf;
u32 len;
};
void megasas_free_cmds_fusion(struct megasas_instance *instance); void megasas_free_cmds_fusion(struct megasas_instance *instance);
int megasas_ioc_init_fusion(struct megasas_instance *instance); int megasas_ioc_init_fusion(struct megasas_instance *instance);
u8 megasas_get_map_info(struct megasas_instance *instance); u8 megasas_get_map_info(struct megasas_instance *instance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment