From: Nilay Shroff Date: Sat, 16 May 2026 18:36:48 +0000 (+0530) Subject: nvme: add diag attribute group under sysfs X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=37afebc79a11bd889fe8e0a98c9ae034c3cff323;p=thirdparty%2Fkernel%2Flinux.git nvme: add diag attribute group under sysfs Add a new diag attribute group under: /sys/class/nvme// /sys/block// /sys/block// This new sysfs attribute group will be used to organize NVMe diagnostic and telemetry-related counters under it. Tested-by: Venkat Rao Bagalkote Signed-off-by: Nilay Shroff Signed-off-by: Keith Busch --- diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 86b09c06b9e0a..46cfce4dbbf6e 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 d20d8722ad967..cf71922397826 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 1f471f2cfd251..1d507a835783b 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, };