Commit ca008aee authored by Karan Tilak Kumar's avatar Karan Tilak Kumar Committed by Martin K. Petersen

scsi: fnic: Add and use fnic number

Add fnic_num in fnic.h to identify fnic in a multi-fnic environment.
Increment and set the fnic number during driver load in fnic_probe.
Replace the host number with fnic number in debugfs.
Reviewed-by: default avatarSesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: default avatarArulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: default avatarKaran Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-3-kartilak@cisco.comSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 2cda90e6
......@@ -216,6 +216,7 @@ struct fnic_event {
/* Per-instance private data structure */
struct fnic {
int fnic_num;
struct fc_lport *lport;
struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */
struct vnic_dev_bar bar0;
......
......@@ -39,6 +39,7 @@ static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES];
static struct kmem_cache *fnic_io_req_cache;
static LIST_HEAD(fnic_list);
static DEFINE_SPINLOCK(fnic_list_lock);
static DEFINE_IDA(fnic_ida);
/* Supported devices by fnic module */
static struct pci_device_id fnic_id_table[] = {
......@@ -583,7 +584,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct fc_lport *lp;
struct fnic *fnic;
mempool_t *pool;
int err;
int err = 0;
int fnic_id = 0;
int i;
unsigned long flags;
......@@ -597,8 +599,16 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err = -ENOMEM;
goto err_out;
}
host = lp->host;
fnic = lport_priv(lp);
fnic_id = ida_alloc(&fnic_ida, GFP_KERNEL);
if (fnic_id < 0) {
pr_err("Unable to alloc fnic ID\n");
err = fnic_id;
goto err_out_ida_alloc;
}
fnic->lport = lp;
fnic->ctlr.lp = lp;
......@@ -608,7 +618,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
host->host_no);
host->transportt = fnic_fc_transport;
fnic->fnic_num = fnic_id;
fnic_stats_debugfs_init(fnic);
/* Setup PCI resources */
......@@ -951,6 +961,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_disable_device(pdev);
err_out_free_hba:
fnic_stats_debugfs_remove(fnic);
ida_free(&fnic_ida, fnic->fnic_num);
err_out_ida_alloc:
scsi_host_put(lp->host);
err_out:
return err;
......@@ -1031,6 +1043,7 @@ static void fnic_remove(struct pci_dev *pdev)
fnic_iounmap(fnic);
pci_release_regions(pdev);
pci_disable_device(pdev);
ida_free(&fnic_ida, fnic->fnic_num);
scsi_host_put(lp->host);
}
......@@ -1168,6 +1181,7 @@ static void __exit fnic_cleanup_module(void)
fnic_trace_free();
fnic_fc_trace_free();
fnic_debugfs_terminate();
ida_destroy(&fnic_ida);
}
module_init(fnic_init_module);
......
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