[PATCHv4 1/8] nvme: add diag attribute group under sysfs
Nilay Shroff
nilay at linux.ibm.com
Sat May 16 11:36:48 PDT 2026
Add a new diag attribute group under:
/sys/class/nvme/<ctrl>/
/sys/block/<nvme-path-dev>/
/sys/block/<ns-head-dev>/
This new sysfs attribute group will be used to organize NVMe diagnostic
and telemetry-related counters under it.
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
drivers/nvme/host/nvme.h | 1 +
drivers/nvme/host/pci.c | 1 +
drivers/nvme/host/sysfs.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index ccd5e05dac98..c8225d594252 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1012,6 +1012,7 @@ extern const struct attribute_group nvme_ns_mpath_attr_group;
extern const struct pr_ops nvme_pr_ops;
extern const struct block_device_operations nvme_ns_head_ops;
extern const struct attribute_group nvme_dev_attrs_group;
+extern const struct attribute_group nvme_dev_diag_attrs_group;
extern const struct attribute_group *nvme_subsys_attrs_groups[];
extern const struct attribute_group *nvme_dev_attr_groups[];
extern const struct block_device_operations nvme_bdev_ops;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 9fd04cd7c5cb..3f7bdf0fa786 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2810,6 +2810,7 @@ static const struct attribute_group nvme_pci_dev_attrs_group = {
static const struct attribute_group *nvme_pci_dev_attr_groups[] = {
&nvme_dev_attrs_group,
&nvme_pci_dev_attrs_group,
+ &nvme_dev_diag_attrs_group,
NULL,
};
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index e59758616f27..cc569c8556f3 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -351,11 +351,28 @@ const struct attribute_group nvme_ns_mpath_attr_group = {
};
#endif
+static struct attribute *nvme_ns_diag_attrs[] = {
+ NULL,
+};
+
+static umode_t nvme_ns_diag_attrs_are_visible(struct kobject *kobj,
+ struct attribute *a, int n)
+{
+ return a->mode;
+}
+
+const struct attribute_group nvme_ns_diag_attr_group = {
+ .name = "diag",
+ .attrs = nvme_ns_diag_attrs,
+ .is_visible = nvme_ns_diag_attrs_are_visible,
+};
+
const struct attribute_group *nvme_ns_attr_groups[] = {
&nvme_ns_attr_group,
#ifdef CONFIG_NVME_MULTIPATH
&nvme_ns_mpath_attr_group,
#endif
+ &nvme_ns_diag_attr_group,
NULL,
};
@@ -937,11 +954,29 @@ static const struct attribute_group nvme_tls_attrs_group = {
};
#endif
+static struct attribute *nvme_dev_diag_attrs[] = {
+ NULL,
+};
+
+static umode_t nvme_dev_diag_attrs_are_visible(struct kobject *kobj,
+ struct attribute *a, int n)
+{
+ return a->mode;
+}
+
+const struct attribute_group nvme_dev_diag_attrs_group = {
+ .name = "diag",
+ .attrs = nvme_dev_diag_attrs,
+ .is_visible = nvme_dev_diag_attrs_are_visible,
+};
+EXPORT_SYMBOL_GPL(nvme_dev_diag_attrs_group);
+
const struct attribute_group *nvme_dev_attr_groups[] = {
&nvme_dev_attrs_group,
#ifdef CONFIG_NVME_TCP_TLS
&nvme_tls_attrs_group,
#endif
+ &nvme_dev_diag_attrs_group,
NULL,
};
--
2.53.0
More information about the Linux-nvme
mailing list