Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jsmart2021@gmail.com (James Smart)
Subject: [PATCH v3 1/3] nvme_fc: create fc class and transport device
Date: Thu, 14 Sep 2017 10:38:41 -0700	[thread overview]
Message-ID: <20170914173843.3195-2-jsmart2021@gmail.com> (raw)
In-Reply-To: <20170914173843.3195-1-jsmart2021@gmail.com>

Added a new fc class and a device node for udev events under it.
I expect the fc class will eventually be the location where the
FC SCSI and FC NVME merge in the future. Therefore names are
kept somewhat generic.

Signed-off-by: James Smart <james.smart at broadcom.com>
---
v3:
  Genericized udev event device name.
  Added comments about future expectations.
  Kept fc class and udev device in the nvme module due to its
     small size. in future, it can move to somewhere else.

 drivers/nvme/host/fc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index d2e882c0f496..f9e9dddc7e92 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -213,6 +213,13 @@ static DEFINE_IDA(nvme_fc_ctrl_cnt);
 
 
 
+/*
+ * These items are short-term. They will eventually be moved into
+ * a generic FC class. See comments in module init.
+ */
+static struct class *fc_class;
+static struct device *fc_udev_device;
+
 
 /* *********************** FC-NVME Port Management ************************ */
 
@@ -2996,7 +3003,50 @@ static struct nvmf_transport_ops nvme_fc_transport = {
 
 static int __init nvme_fc_init_module(void)
 {
-	return nvmf_register_transport(&nvme_fc_transport);
+	int ret;
+
+	/*
+	 * NOTE:
+	 * It is expected that in the future the kernel will combine
+	 * the FC-isms that are currently under scsi and now being
+	 * added to by NVME into a new standalone FC class. The SCSI
+	 * and NVME protocols and their devices would be under this
+	 * new FC class.
+	 *
+	 * As we need something to post FC-specific udev events to,
+	 * specifically for nvme probe events, start by creating the
+	 * new device class.  When the new standalone FC class is
+	 * put in place, this code will move to a more generic
+	 * location for the class.
+	 */
+	fc_class = class_create(THIS_MODULE, "fc");
+	if (IS_ERR(fc_class)) {
+		pr_err("couldn't register class fc\n");
+		return PTR_ERR(fc_class);
+	}
+
+	/*
+	 * Create a device for the FC-centric udev events
+	 */
+	fc_udev_device = device_create(fc_class, NULL, MKDEV(0, 0), NULL,
+				"fc_udev_device");
+	if (IS_ERR(fc_udev_device)) {
+		pr_err("couldn't create fc_udev device!\n");
+		ret = PTR_ERR(fc_udev_device);
+		goto out_destroy_class;
+	}
+
+	ret = nvmf_register_transport(&nvme_fc_transport);
+	if (ret)
+		goto out_destroy_device;
+
+	return 0;
+
+out_destroy_device:
+	device_destroy(fc_class, MKDEV(0, 0));
+out_destroy_class:
+	class_destroy(fc_class);
+	return ret;
 }
 
 static void __exit nvme_fc_exit_module(void)
@@ -3009,6 +3059,9 @@ static void __exit nvme_fc_exit_module(void)
 
 	ida_destroy(&nvme_fc_local_port_cnt);
 	ida_destroy(&nvme_fc_ctrl_cnt);
+
+	device_destroy(fc_class, MKDEV(0, 0));
+	class_destroy(fc_class);
 }
 
 module_init(nvme_fc_init_module);
-- 
2.13.1

  reply	other threads:[~2017-09-14 17:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 17:38 [PATCH v3 0/3] nvme_fc: add uevent to allow dynamic connects James Smart
2017-09-14 17:38 ` James Smart [this message]
2017-09-18 16:13   ` [PATCH v3 1/3] nvme_fc: create fc class and transport device Christoph Hellwig
2017-09-20 10:30     ` Johannes Thumshirn
2017-09-20 17:50       ` Christoph Hellwig
2017-09-21  5:16         ` Johannes Thumshirn
2017-09-14 17:38 ` [PATCH v3 2/3] nvme_fc: add uevent for auto-connect James Smart
2017-09-18 16:14   ` Christoph Hellwig
2017-09-19 14:53     ` James Smart
2017-09-20 17:50       ` Christoph Hellwig
2017-09-14 17:38 ` [PATCH v3 3/3] nvme_fc: Avoid duplicate associations between same port pairs James Smart
2017-09-18 16:12   ` Christoph Hellwig
2017-09-18 16:28     ` James Smart
2017-09-18 23:17       ` Christoph Hellwig
2017-09-19  0:07         ` James Smart
2017-09-20 11:09           ` Sagi Grimberg
2017-10-04  7:48 ` [PATCH v3 0/3] nvme_fc: add uevent to allow dynamic connects Christoph Hellwig

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=20170914173843.3195-2-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.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