All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: expose cntlid in sysfs
@ 2016-02-26 21:24 Ming Lin
  2016-02-26 23:09 ` Keith Busch
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ming Lin @ 2016-02-26 21:24 UTC (permalink / raw)


From: Ming Lin <ming.l@ssi.samsung.com>

For NVMe over Fabrics, the cntlid will be used by systemd/udev to
create link to the device, for example,

/dev/disk/by-path/<fabrics-info>-<cntlid>-<namespace> -> /dev/nvme0n1

Signed-off-by: Ming Lin <ming.l at ssi.samsung.com>
---
 drivers/nvme/host/core.c | 20 ++++++++++++++++----
 drivers/nvme/host/nvme.h |  1 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c7df0ab..0b04119 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -901,6 +901,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->oncs = le16_to_cpup(&id->oncs);
 	atomic_set(&ctrl->abort_limit, id->acl + 1);
 	ctrl->vwc = id->vwc;
+	ctrl->cntlid = le16_to_cpup(&id->cntlid);
 	memcpy(ctrl->serial, id->sn, sizeof(id->sn));
 	memcpy(ctrl->model, id->mn, sizeof(id->mn));
 	memcpy(ctrl->firmware_rev, id->fr, sizeof(id->fr));
@@ -1088,7 +1089,7 @@ static const struct attribute_group nvme_ns_attr_group = {
 	.is_visible	= nvme_attrs_are_visible,
 };
 
-#define nvme_show_function(field)						\
+#define nvme_show_str_function(field)						\
 static ssize_t  field##_show(struct device *dev,				\
 			    struct device_attribute *attr, char *buf)		\
 {										\
@@ -1097,15 +1098,26 @@ static ssize_t  field##_show(struct device *dev,				\
 }										\
 static DEVICE_ATTR(field, S_IRUGO, field##_show, NULL);
 
-nvme_show_function(model);
-nvme_show_function(serial);
-nvme_show_function(firmware_rev);
+#define nvme_show_int_function(field)						\
+static ssize_t  field##_show(struct device *dev,				\
+			    struct device_attribute *attr, char *buf)		\
+{										\
+        struct nvme_ctrl *ctrl = dev_get_drvdata(dev);				\
+        return sprintf(buf, "%d\n", ctrl->field);	\
+}										\
+static DEVICE_ATTR(field, S_IRUGO, field##_show, NULL);
+
+nvme_show_str_function(model);
+nvme_show_str_function(serial);
+nvme_show_str_function(firmware_rev);
+nvme_show_int_function(cntlid);
 
 static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_reset_controller.attr,
 	&dev_attr_model.attr,
 	&dev_attr_serial.attr,
 	&dev_attr_firmware_rev.attr,
+	&dev_attr_cntlid.attr,
 	NULL
 };
 
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 63ba8a5..2e041e7 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -77,6 +77,7 @@ struct nvme_ctrl {
 	char serial[20];
 	char model[40];
 	char firmware_rev[8];
+	int cntlid;
 
 	u32 ctrl_config;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] nvme: expose cntlid in sysfs
  2016-02-26 21:24 [PATCH] nvme: expose cntlid in sysfs Ming Lin
@ 2016-02-26 23:09 ` Keith Busch
  2016-02-28  9:10 ` Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2016-02-26 23:09 UTC (permalink / raw)


On Fri, Feb 26, 2016@01:24:19PM -0800, Ming Lin wrote:
> From: Ming Lin <ming.l at ssi.samsung.com>
> 
> For NVMe over Fabrics, the cntlid will be used by systemd/udev to
> create link to the device, for example,
> 
> /dev/disk/by-path/<fabrics-info>-<cntlid>-<namespace> -> /dev/nvme0n1

Looks good. Sounds horrific if I try to pronounce it, but the spec
abbreviated "controller" that way!

Reviewed-by: Keith Busch <keith.busch at intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: expose cntlid in sysfs
  2016-02-26 21:24 [PATCH] nvme: expose cntlid in sysfs Ming Lin
  2016-02-26 23:09 ` Keith Busch
@ 2016-02-28  9:10 ` Christoph Hellwig
  2016-02-28 11:18 ` Sagi Grimberg
  2016-02-29 19:31 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2016-02-28  9:10 UTC (permalink / raw)


On Fri, Feb 26, 2016@01:24:19PM -0800, Ming Lin wrote:
> From: Ming Lin <ming.l at ssi.samsung.com>
> 
> For NVMe over Fabrics, the cntlid will be used by systemd/udev to
> create link to the device, for example,

Looks fine,

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: expose cntlid in sysfs
  2016-02-26 21:24 [PATCH] nvme: expose cntlid in sysfs Ming Lin
  2016-02-26 23:09 ` Keith Busch
  2016-02-28  9:10 ` Christoph Hellwig
@ 2016-02-28 11:18 ` Sagi Grimberg
  2016-02-29 19:31 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2016-02-28 11:18 UTC (permalink / raw)


Looks good,

Reviewed-by: Sagi Grimberg <sagig at mellanox.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nvme: expose cntlid in sysfs
  2016-02-26 21:24 [PATCH] nvme: expose cntlid in sysfs Ming Lin
                   ` (2 preceding siblings ...)
  2016-02-28 11:18 ` Sagi Grimberg
@ 2016-02-29 19:31 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2016-02-29 19:31 UTC (permalink / raw)


On 02/26/2016 02:24 PM, Ming Lin wrote:
> From: Ming Lin <ming.l at ssi.samsung.com>
>
> For NVMe over Fabrics, the cntlid will be used by systemd/udev to
> create link to the device, for example,
>
> /dev/disk/by-path/<fabrics-info>-<cntlid>-<namespace> -> /dev/nvme0n1

Added for 4.6 with the acks, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-29 19:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-26 21:24 [PATCH] nvme: expose cntlid in sysfs Ming Lin
2016-02-26 23:09 ` Keith Busch
2016-02-28  9:10 ` Christoph Hellwig
2016-02-28 11:18 ` Sagi Grimberg
2016-02-29 19:31 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.