public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Karan Tilak Kumar <kartilak@cisco.com>
To: sebaddel@cisco.com
Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com,
	mkai2@cisco.com, satishkh@cisco.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Karan Tilak Kumar <kartilak@cisco.com>
Subject: [PATCH v4 02/13] scsi: fnic: Add and use fnic number
Date: Wed, 29 Nov 2023 18:33:51 -0800	[thread overview]
Message-ID: <20231130023402.802282-3-kartilak@cisco.com> (raw)
In-Reply-To: <20231130023402.802282-1-kartilak@cisco.com>

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>

Changes between v3 and v4:
    Incorporate review comments from Martin and Hannes:
	Undo the change to replace host number with fnic
	number in debugfs since kernel stack uses host number.
	Use ida_alloc to allocate ID for fnic number.
---
 drivers/scsi/fnic/fnic.h      |  1 +
 drivers/scsi/fnic/fnic_main.c | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 93c68931a593..c6c549c633b1 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -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;
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 984bc5fc55e2..f989a5d7a229 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -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 */
@@ -949,6 +959,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;
@@ -1029,6 +1041,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);
 }
 
@@ -1166,6 +1179,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);
-- 
2.31.1


  parent reply	other threads:[~2023-11-30  2:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30  2:33 [PATCH v4 00/13] Introduce support for multiqueue (MQ) in fnic Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 01/13] scsi: fnic: Modify definitions to sync with VIC firmware Karan Tilak Kumar
2023-11-30  2:33 ` Karan Tilak Kumar [this message]
2023-11-30  2:33 ` [PATCH v4 03/13] scsi: fnic: Add and improve log messages Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 04/13] scsi: fnic: Rename wq_copy to hw_copy_wq Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 05/13] scsi: fnic: Get copy workqueue count and interrupt mode from config Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 06/13] scsi: fnic: Refactor and redefine fnic.h for multiqueue Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 07/13] scsi: fnic: Modify ISRs to support multiqueue(MQ) Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 08/13] scsi: fnic: Define stats to track multiqueue (MQ) IOs Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 09/13] scsi: fnic: Remove usage of host_lock Karan Tilak Kumar
2023-11-30  2:33 ` [PATCH v4 10/13] scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c Karan Tilak Kumar
2023-11-30  2:34 ` [PATCH v4 11/13] scsi: fnic: Add support for multiqueue (MQ) in fnic driver Karan Tilak Kumar
2023-11-30  2:34 ` [PATCH v4 12/13] scsi: fnic: Improve logs and add support for multiqueue (MQ) Karan Tilak Kumar
2023-11-30  2:34 ` [PATCH v4 13/13] scsi: fnic: Increment driver version Karan Tilak Kumar
2023-12-06  3:10 ` [PATCH v4 00/13] Introduce support for multiqueue (MQ) in fnic Martin K. Petersen
2023-12-06  3:53   ` Karan Tilak Kumar (kartilak)
2023-12-08 18:03     ` Martin K. Petersen
2023-12-08 19:20       ` Karan Tilak Kumar (kartilak)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130023402.802282-3-kartilak@cisco.com \
    --to=kartilak@cisco.com \
    --cc=arulponn@cisco.com \
    --cc=djhawar@cisco.com \
    --cc=gcboffa@cisco.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mkai2@cisco.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox