]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvme: add diag attribute group under sysfs
authorNilay Shroff <nilay@linux.ibm.com>
Sat, 16 May 2026 18:36:48 +0000 (00:06 +0530)
committerKeith Busch <kbusch@kernel.org>
Thu, 4 Jun 2026 08:57:06 +0000 (01:57 -0700)
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>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c
drivers/nvme/host/sysfs.c

index 86b09c06b9e0a19d30cc22ea8662f9997a858611..46cfce4dbbf6ec42cff650abeeaf3ca57171bb02 100644 (file)
@@ -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;
index d20d8722ad9673bec0c3bee73e131c15c3aa1319..cf7192239782632fc4cab8bcbe9950c6523b4cb6 100644 (file)
@@ -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,
 };
 
index 1f471f2cfd2519e9edfe6e2de475abaeb6b8903c..1d507a835783b4afd2be52714e699d2012276575 100644 (file)
@@ -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,
 };