summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNilay Shroff <nilay@linux.ibm.com>2026-05-17 00:06:48 +0530
committerKeith Busch <kbusch@kernel.org>2026-06-04 01:57:06 -0700
commit37afebc79a11bd889fe8e0a98c9ae034c3cff323 (patch)
tree971814006a88e91ab4b9c9986dc0886335048efe
parent19bdb70c77d3b24239a453291299b64040bdba86 (diff)
downloadlinux-stable-37afebc79a11bd889fe8e0a98c9ae034c3cff323.tar.gz
linux-stable-37afebc79a11bd889fe8e0a98c9ae034c3cff323.zip
nvme: add diag attribute group under sysfs
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. Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
-rw-r--r--drivers/nvme/host/nvme.h1
-rw-r--r--drivers/nvme/host/pci.c1
-rw-r--r--drivers/nvme/host/sysfs.c35
3 files changed, 37 insertions, 0 deletions
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 86b09c06b9e0..46cfce4dbbf6 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1014,6 +1014,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 d20d8722ad96..cf7192239782 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2815,6 +2815,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 1f471f2cfd25..1d507a835783 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -344,11 +344,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,
};
@@ -1018,11 +1035,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,
};