Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp158757imm; Tue, 19 Jun 2018 18:14:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJf3h/TSwEYU2AcVbp2hmupvBN5ByW7D9ssTuelkFjSFVNpzjesXQNUyc3efCnOmWfV16Xo X-Received: by 2002:a63:d8:: with SMTP id 207-v6mr161816pga.94.1529457291358; Tue, 19 Jun 2018 18:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529457291; cv=none; d=google.com; s=arc-20160816; b=t5ur+BTQvjh8Kau91M7tsX+C1GE0hV40mq1qEKzMsbNkseWh8haaU42F8rMC69zCKg ectu+EO7a/6W8zFwv2EfS2kP5ch/6ZgzPEREZkoasOiqtCl5NaQCOz/xIem7HtpdGHKo aV0MDio/mvtJVom8w+0TyEHWW9NEbZuIkpI99doeWwH09v40/xgIGLxXVV/8tyn2XxRX XTQS28sjfO8cND1uLWPB4wJ0Nqx3WrpU0JPG1SmJFa3f14SrKH//LmsTnFbimfEmnXiT +cP+ivl+jSFfKwDZJd9UiNIdmPRoSE9VcGLrvhfIm7y3W09NbRyUxUStNI7qQ7ZNvBq0 NoWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references:message-id :in-reply-to:date:mime-version:dkim-signature :arc-authentication-results; bh=3Y+QluKJwrqjzjy8KY30yUXxcpwjF/AHZBdPidFilXs=; b=BygYejdTDrUvsHGh2CcwgpbfB+8ktosBe+dqusBnIgz/+SloX2s1TvePGWh1JMgXsT LSpqhS2UHr6SJ0drPONVBvbf5x16QmFObAEQPTMUjaQZmwHXPdjHQzmyfZS+WsvXICYs n0HkNFPgWSi+ySzoZ10X2Usohppt0NFWuGpe5mkkIK+h4Pp6nCDRkfmhQh3OqYsjnYf5 Bxwae4Nf6DuDOmKypjR+SFN6pap/20+HrEHtVr/QzFVBKu9rY+Wi9kF8pkSN28bFc0Nb wOUdJrRpQIr9q1ZPEGj+9xEJkd+dJn31/lPASFC4mZpy/YfZ2BoPF/yBQQQqZt6F0nwa yPUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xz5SW4jo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e82-v6si1118669pfm.220.2018.06.19.18.14.37; Tue, 19 Jun 2018 18:14:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xz5SW4jo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754178AbeFTBNJ (ORCPT + 99 others); Tue, 19 Jun 2018 21:13:09 -0400 Received: from mail-ua0-f201.google.com ([209.85.217.201]:46422 "EHLO mail-ua0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753917AbeFTBMZ (ORCPT ); Tue, 19 Jun 2018 21:12:25 -0400 Received: by mail-ua0-f201.google.com with SMTP id m1-v6so509183uao.13 for ; Tue, 19 Jun 2018 18:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=3Y+QluKJwrqjzjy8KY30yUXxcpwjF/AHZBdPidFilXs=; b=Xz5SW4joaesf7pBEyzVH/YP4nCqavwPvyLywEK/aCntTgxLyVyPjT+xCWxIoxhsLA+ HPzVndo30GImyXLbqBCmtLK8sO3NDO7lJOrI+UT+hMuuMuKKZVT66yOZPXvdkSOsolc2 vpixwsEy1T0ipVpf+JJOYap6Ag+QZzAlf7OLMHT14HKbYIp76nOPau1d6xLY373EcqwB lOCs77Lr2JoFt/S9IQ/pnyPOf94YdJmhUVR0OdUZOJOBv1UYXURtiyzHBYodx7g9xJHJ xChd42wqzxaUszOx/16/6sjVeIP+KltMbxfdAcvl88ODaLKu84jKdaLCEzOH9rPHKG7r +r+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=3Y+QluKJwrqjzjy8KY30yUXxcpwjF/AHZBdPidFilXs=; b=Ostya0y3vCZ8y9fAXFKM9PyXY0Wx2Pt8EoXp2htad5daBNfzf1qVE7NDtxAzjTwjQ0 AVYeqbr2tVXeA92e+86NCI94k7EXwWquuTdfSw0qDVx76mG1r/12AU+VGfF06BeL/gKR IH7TptD0RaFzJtVrCs8KOYtte2/krc+rECKrzbLv547tMpmd9tpeie8l7A+wTSvw8xMR 196T2fWCDwfALFtB2fVptIqJh4ON2/gdBCZ3mxw5NQG5uUv86eMNGAhEIECe9d2xE4K4 tkjes03hiPfRgn0OyzqyOQrc4E3kMVFqQ/aHrMQ5QqpITXvHYs0zPAUxV+dN6vhdLxAV K7dw== X-Gm-Message-State: APt69E2aJQNpClRQuwoAA4HTx1zGO+ZV+3i8rlJjar+6e49llEPQZFDF /a+g+KqFqUpxF3RplF1qGu7umohc9RES MIME-Version: 1.0 X-Received: by 2002:a9f:21b4:: with SMTP id 49-v6mr8325832uac.16.1529457144592; Tue, 19 Jun 2018 18:12:24 -0700 (PDT) Date: Tue, 19 Jun 2018 18:12:08 -0700 In-Reply-To: <20180620011210.254601-1-rajatja@google.com> Message-Id: <20180620011210.254601-3-rajatja@google.com> References: <20180619221651.GH33049@bhelgaas-glaptop.roam.corp.google.com> <20180620011210.254601-1-rajatja@google.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog Subject: [PATCH v3 3/5] PCI/AER: Add sysfs attributes to provide breakdown of AERs From: Rajat Jain To: Bjorn Helgaas , Jonathan Corbet , Philippe Ombredanne , Kate Stewart , Thomas Gleixner , Greg Kroah-Hartman , Frederick Lawler , Oza Pawandeep , Keith Busch , Alexandru Gagniuc , Thomas Tai , "Steven Rostedt (VMware)" , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jes Sorensen , Kyle McMartin , rajatxjain@gmail.com, helgaas@kernel.org Cc: Rajat Jain , Rajat Jain Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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