mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 08:15:07 -04:00
scsi: fnic: Expose NVMe transport state in debugfs
Create an NVMe debugfs directory with a per-host nvmef_info file. Report local-port and target-port identifiers for NVMe initiator instances, and initialize and remove the debugfs entries with the NVMe probe and teardown paths. Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com> Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com> Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com> Reviewed-by: Arun Easi <aeasi@cisco.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Lee Duncan <lduncan@suse.com> Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com> Co-developed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260724174811.5118-13-kartilak@cisco.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
d25a557d34
commit
8ef412ce8b
@@ -478,6 +478,8 @@ struct fnic {
|
||||
/*** FIP related data members -- end ***/
|
||||
|
||||
/* NVME data members */
|
||||
struct dentry *fnic_nvmef_debugfs_host;
|
||||
struct dentry *fnic_nvmef_debugfs_file;
|
||||
struct sbitmap nvfnic_tag_map;
|
||||
struct work_struct nvme_io_cmpl_work;
|
||||
atomic_t nvme_io_event_queued;
|
||||
@@ -551,6 +553,9 @@ void fnic_log_q_error(struct fnic *fnic);
|
||||
void fnic_handle_link_event(struct fnic *fnic);
|
||||
int fnic_stats_debugfs_init(struct fnic *fnic);
|
||||
void fnic_stats_debugfs_remove(struct fnic *fnic);
|
||||
void fnic_nvmef_debugfs_init(struct fnic *fnic);
|
||||
void fnic_nvmef_debugfs_remove(struct fnic *fnic);
|
||||
int nvfnic_get_nvmef_info(struct fnic *fnic, struct fnic_nvmef_info *info);
|
||||
int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);
|
||||
|
||||
void fnic_handle_fip_frame(struct work_struct *work);
|
||||
|
||||
@@ -10,10 +10,19 @@
|
||||
extern int fnic_get_debug_info(struct stats_debug_info *debug_buffer,
|
||||
struct fnic *fnic);
|
||||
|
||||
static int fnic_nvmef_debugfs_open(struct inode *inode,
|
||||
struct file *file);
|
||||
static ssize_t fnic_nvmef_debugfs_read(struct file *file,
|
||||
char __user *ubuf,
|
||||
size_t nbytes, loff_t *pos);
|
||||
static int fnic_nvmef_debugfs_release(struct inode *inode,
|
||||
struct file *file);
|
||||
|
||||
static struct dentry *fnic_trace_debugfs_root;
|
||||
static struct dentry *fnic_trace_debugfs_file;
|
||||
static struct dentry *fnic_trace_enable;
|
||||
static struct dentry *fnic_stats_debugfs_root;
|
||||
static struct dentry *fnic_nvmef_debugfs_root;
|
||||
|
||||
static struct dentry *fnic_fc_trace_debugfs_file;
|
||||
static struct dentry *fnic_fc_rdata_trace_debugfs_file;
|
||||
@@ -46,6 +55,9 @@ int fnic_debugfs_init(void)
|
||||
fnic_stats_debugfs_root = debugfs_create_dir("statistics",
|
||||
fnic_trace_debugfs_root);
|
||||
|
||||
fnic_nvmef_debugfs_root = debugfs_create_dir("nvme_info",
|
||||
fnic_trace_debugfs_root);
|
||||
|
||||
/* Allocate memory to structure */
|
||||
fc_trc_flag = vmalloc(sizeof(struct fc_trace_flag_type));
|
||||
|
||||
@@ -70,6 +82,9 @@ int fnic_debugfs_init(void)
|
||||
*/
|
||||
void fnic_debugfs_terminate(void)
|
||||
{
|
||||
debugfs_remove(fnic_nvmef_debugfs_root);
|
||||
fnic_nvmef_debugfs_root = NULL;
|
||||
|
||||
debugfs_remove(fnic_stats_debugfs_root);
|
||||
fnic_stats_debugfs_root = NULL;
|
||||
|
||||
@@ -669,6 +684,13 @@ static const struct file_operations fnic_reset_debugfs_fops = {
|
||||
.release = fnic_reset_stats_release,
|
||||
};
|
||||
|
||||
static const struct file_operations fnic_nvmef_debugfs_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = fnic_nvmef_debugfs_open,
|
||||
.read = fnic_nvmef_debugfs_read,
|
||||
.release = fnic_nvmef_debugfs_release,
|
||||
};
|
||||
|
||||
/*
|
||||
* fnic_stats_init - Initialize stats struct and create stats file per fnic
|
||||
*
|
||||
@@ -722,3 +744,75 @@ void fnic_stats_debugfs_remove(struct fnic *fnic)
|
||||
debugfs_remove(fnic->fnic_stats_debugfs_host);
|
||||
fnic->fnic_stats_debugfs_host = NULL;
|
||||
}
|
||||
|
||||
void fnic_nvmef_debugfs_init(struct fnic *fnic)
|
||||
{
|
||||
char name[16];
|
||||
|
||||
snprintf(name, sizeof(name), "host%d", fnic->fnic_num);
|
||||
|
||||
fnic->fnic_nvmef_debugfs_host = debugfs_create_dir(name,
|
||||
fnic_nvmef_debugfs_root);
|
||||
fnic->fnic_nvmef_debugfs_file = debugfs_create_file("nvmef_info",
|
||||
S_IFREG | 0444,
|
||||
fnic->fnic_nvmef_debugfs_host,
|
||||
fnic,
|
||||
&fnic_nvmef_debugfs_fops);
|
||||
}
|
||||
|
||||
static int fnic_nvmef_debugfs_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
|
||||
struct fnic *fnic = inode->i_private;
|
||||
struct fnic_nvmef_info *info;
|
||||
int buf_size = 2 * PAGE_SIZE;
|
||||
|
||||
info = kzalloc_obj(struct fnic_nvmef_info, GFP_KERNEL);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
info->info_buffer = vmalloc(buf_size);
|
||||
if (!info->info_buffer) {
|
||||
kfree(info);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
info->buf_size = buf_size;
|
||||
memset((void *)info->info_buffer, 0, buf_size);
|
||||
info->buffer_len = nvfnic_get_nvmef_info(fnic, info);
|
||||
|
||||
file->private_data = info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t fnic_nvmef_debugfs_read(struct file *file,
|
||||
char __user *ubuf,
|
||||
size_t nbytes, loff_t *pos)
|
||||
{
|
||||
struct fnic_nvmef_info *info = file->private_data;
|
||||
|
||||
return simple_read_from_buffer(ubuf, nbytes, pos,
|
||||
info->info_buffer, info->buffer_len);
|
||||
}
|
||||
|
||||
static int fnic_nvmef_debugfs_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct fnic_nvmef_info *info = file->private_data;
|
||||
|
||||
vfree(info->info_buffer);
|
||||
kfree(info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fnic_nvmef_debugfs_remove(struct fnic *fnic)
|
||||
{
|
||||
if (!fnic)
|
||||
return;
|
||||
|
||||
debugfs_remove(fnic->fnic_nvmef_debugfs_file);
|
||||
fnic->fnic_nvmef_debugfs_file = NULL;
|
||||
|
||||
debugfs_remove(fnic->fnic_nvmef_debugfs_host);
|
||||
fnic->fnic_nvmef_debugfs_host = NULL;
|
||||
}
|
||||
|
||||
@@ -936,6 +936,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
err = -EOPNOTSUPP;
|
||||
goto err_out_fnic_role;
|
||||
case VFCF_FC_NVME_INITIATOR:
|
||||
fnic_nvmef_debugfs_init(fnic);
|
||||
fnic->role = FNIC_ROLE_NVME_INITIATOR;
|
||||
dev_info(&fnic->pdev->dev, "fnic: %d is NVME initiator\n",
|
||||
fnic->fnic_num);
|
||||
@@ -1210,6 +1211,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
err_out_fnic_alloc_vnic_res:
|
||||
fnic_clear_intr_mode(fnic);
|
||||
err_out_fnic_set_intr_mode:
|
||||
if (IS_FNIC_NVME_INITIATOR(fnic))
|
||||
fnic_nvmef_debugfs_remove(fnic);
|
||||
if (IS_FNIC_FCP_INITIATOR(fnic))
|
||||
scsi_host_put(fnic->host);
|
||||
err_out_fnic_role:
|
||||
@@ -1280,6 +1283,7 @@ static void fnic_remove(struct pci_dev *pdev)
|
||||
if ((fnic_fdmi_support == 1) && (fnic->iport.fabric.fdmi_pending > 0))
|
||||
timer_delete_sync(&fnic->iport.fabric.fdmi_timer);
|
||||
|
||||
fnic_nvmef_debugfs_remove(fnic);
|
||||
fnic_stats_debugfs_remove(fnic);
|
||||
|
||||
/*
|
||||
|
||||
@@ -188,6 +188,36 @@ void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport,
|
||||
fnic->io_sgl_pool[io_req->sgl_type]);
|
||||
}
|
||||
|
||||
int nvfnic_get_nvmef_info(struct fnic *fnic, struct fnic_nvmef_info *info)
|
||||
{
|
||||
int len = 0;
|
||||
struct fnic_iport_s *iport = &fnic->iport;
|
||||
int buf_size = info->buf_size;
|
||||
struct fnic_tport_s *tport;
|
||||
struct fnic_tport_s *next;
|
||||
unsigned long flags;
|
||||
|
||||
if (buf_size <= 0)
|
||||
return 0;
|
||||
|
||||
len += scnprintf(info->info_buffer + len, buf_size - len,
|
||||
"lport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n",
|
||||
iport->wwpn, iport->wwnn, iport->fcid);
|
||||
|
||||
spin_lock_irqsave(&fnic->fnic_lock, flags);
|
||||
list_for_each_entry_safe(tport, next, &iport->tport_list, links) {
|
||||
if (len >= buf_size - 1)
|
||||
break;
|
||||
|
||||
len += scnprintf(info->info_buffer + len, buf_size - len,
|
||||
"tport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n",
|
||||
tport->wwpn, tport->wwnn, tport->fcid);
|
||||
}
|
||||
spin_unlock_irqrestore(&fnic->fnic_lock, flags);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
inline int nvfnic_queue_wq_nvme_copy_desc(struct fnic *fnic,
|
||||
struct vnic_wq_copy *wq,
|
||||
struct fnic_io_req *io_req,
|
||||
|
||||
@@ -134,6 +134,7 @@ void nvfnic_terminate_tport_admin_ios(struct fnic *fnic,
|
||||
struct fnic_tport_s *tport);
|
||||
void nvfnic_cleanup_tport_io(struct fnic *fnic, struct fnic_tport_s *tport);
|
||||
void nvfnic_nvme_unload(struct fnic *fnic);
|
||||
int nvfnic_get_nvmef_info(struct fnic *fnic, struct fnic_nvmef_info *info);
|
||||
void nvfnic_exch_reset(struct fnic_iport_s *iport, struct fnic_tport_s *tport);
|
||||
void nvfnic_nvme_iodone_work(struct work_struct *work);
|
||||
#else
|
||||
|
||||
@@ -191,6 +191,13 @@ struct stats_debug_info {
|
||||
int buffer_len;
|
||||
};
|
||||
|
||||
struct fnic_nvmef_info {
|
||||
char *info_buffer;
|
||||
void *i_private;
|
||||
int buf_size;
|
||||
int buffer_len;
|
||||
};
|
||||
|
||||
int fnic_get_stats_data(struct stats_debug_info *, struct fnic_stats *);
|
||||
const char *fnic_role_to_str(unsigned int role);
|
||||
#endif /* _FNIC_STATS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user