[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180620011210.254601-3-rajatja@google.com>
Date: Tue, 19 Jun 2018 18:12:08 -0700
From: Rajat Jain <rajatja@...gle.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Corbet <corbet@....net>,
Philippe Ombredanne <pombredanne@...b.com>,
Kate Stewart <kstewart@...uxfoundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Frederick Lawler <fred@...dlawl.com>,
Oza Pawandeep <poza@...eaurora.org>,
Keith Busch <keith.busch@...el.com>,
Alexandru Gagniuc <mr.nuke.me@...il.com>,
Thomas Tai <thomas.tai@...cle.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>,
linux-pci@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, Jes Sorensen <jsorensen@...com>,
Kyle McMartin <jkkm@...com>, rajatxjain@...il.com,
helgaas@...nel.org
Cc: Rajat Jain <rajatja@...gle.com>, Rajat Jain <rajatj@...gle.com>
Subject: [PATCH v3 3/5] PCI/AER: Add sysfs attributes to provide breakdown of AERs
Add sysfs attributes to provide breakdown of the AERs seen,
into different type of correctable or uncorrectable errors:
dev_breakdown_correctable
dev_breakdown_uncorrectable
Signed-off-by: Rajat Jain <rajatj@...gle.com>
---
v3: Merge everything in aer.c, use "%llu" in place of "%llx"
drivers/pci/pcie/aer.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index ce0d675d7bd3..876f03799810 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -587,10 +587,38 @@ aer_stats_aggregate_attr(dev_total_cor_errs);
aer_stats_aggregate_attr(dev_total_fatal_errs);
aer_stats_aggregate_attr(dev_total_nonfatal_errs);
+#define aer_stats_breakdown_attr(field, stats_array, strings_array) \
+ static ssize_t \
+ field##_show(struct device *dev, struct device_attribute *attr, \
+ char *buf) \
+{ \
+ unsigned int i; \
+ char *str = buf; \
+ struct pci_dev *pdev = to_pci_dev(dev); \
+ u64 *stats = pdev->aer_stats->stats_array; \
+ for (i = 0; i < ARRAY_SIZE(strings_array); i++) { \
+ if (strings_array[i]) \
+ str += sprintf(str, "%s = 0x%llx\n", \
+ strings_array[i], stats[i]); \
+ else if (stats[i]) \
+ str += sprintf(str, #stats_array "bit[%d] = 0x%llx\n",\
+ i, stats[i]); \
+ } \
+ return str-buf; \
+} \
+static DEVICE_ATTR_RO(field)
+
+aer_stats_breakdown_attr(dev_breakdown_correctable, dev_cor_errs,
+ aer_correctable_error_string);
+aer_stats_breakdown_attr(dev_breakdown_uncorrectable, dev_uncor_errs,
+ aer_uncorrectable_error_string);
+
static struct attribute *aer_stats_attrs[] __ro_after_init = {
&dev_attr_dev_total_cor_errs.attr,
&dev_attr_dev_total_fatal_errs.attr,
&dev_attr_dev_total_nonfatal_errs.attr,
+ &dev_attr_dev_breakdown_correctable.attr,
+ &dev_attr_dev_breakdown_uncorrectable.attr,
NULL
};
--
2.18.0.rc1.244.gcf134e6275-goog
Powered by blists - more mailing lists