Skip to content

Commit ca008ae

Browse files
Karan Tilak Kumarmartinkpetersen
authored andcommitted
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: Sesidhar Baddela <sebaddel@cisco.com> Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com> Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com> Link: https://lore.kernel.org/r/20231211173617.932990-3-kartilak@cisco.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2cda90e commit ca008ae

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drivers/scsi/fnic/fnic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct fnic_event {
216216

217217
/* Per-instance private data structure */
218218
struct fnic {
219+
int fnic_num;
219220
struct fc_lport *lport;
220221
struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */
221222
struct vnic_dev_bar bar0;

drivers/scsi/fnic/fnic_main.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES];
3939
static struct kmem_cache *fnic_io_req_cache;
4040
static LIST_HEAD(fnic_list);
4141
static DEFINE_SPINLOCK(fnic_list_lock);
42+
static DEFINE_IDA(fnic_ida);
4243

4344
/* Supported devices by fnic module */
4445
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)
583584
struct fc_lport *lp;
584585
struct fnic *fnic;
585586
mempool_t *pool;
586-
int err;
587+
int err = 0;
588+
int fnic_id = 0;
587589
int i;
588590
unsigned long flags;
589591

@@ -597,8 +599,16 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
597599
err = -ENOMEM;
598600
goto err_out;
599601
}
602+
600603
host = lp->host;
601604
fnic = lport_priv(lp);
605+
606+
fnic_id = ida_alloc(&fnic_ida, GFP_KERNEL);
607+
if (fnic_id < 0) {
608+
pr_err("Unable to alloc fnic ID\n");
609+
err = fnic_id;
610+
goto err_out_ida_alloc;
611+
}
602612
fnic->lport = lp;
603613
fnic->ctlr.lp = lp;
604614

@@ -608,7 +618,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
608618
host->host_no);
609619

610620
host->transportt = fnic_fc_transport;
611-
621+
fnic->fnic_num = fnic_id;
612622
fnic_stats_debugfs_init(fnic);
613623

614624
/* Setup PCI resources */
@@ -951,6 +961,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
951961
pci_disable_device(pdev);
952962
err_out_free_hba:
953963
fnic_stats_debugfs_remove(fnic);
964+
ida_free(&fnic_ida, fnic->fnic_num);
965+
err_out_ida_alloc:
954966
scsi_host_put(lp->host);
955967
err_out:
956968
return err;
@@ -1031,6 +1043,7 @@ static void fnic_remove(struct pci_dev *pdev)
10311043
fnic_iounmap(fnic);
10321044
pci_release_regions(pdev);
10331045
pci_disable_device(pdev);
1046+
ida_free(&fnic_ida, fnic->fnic_num);
10341047
scsi_host_put(lp->host);
10351048
}
10361049

@@ -1168,6 +1181,7 @@ static void __exit fnic_cleanup_module(void)
11681181
fnic_trace_free();
11691182
fnic_fc_trace_free();
11701183
fnic_debugfs_terminate();
1184+
ida_destroy(&fnic_ida);
11711185
}
11721186

11731187
module_init(fnic_init_module);

0 commit comments

Comments
 (0)