From patchwork Tue Feb 6 13:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 197533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1654860dyb; Tue, 6 Feb 2024 08:23:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9ljhctv1O9qGiYBeI3YaHVQd4zkvHPPHcfFbHymVRkeujD5bUQvDEz12qZ6pVnDmniI2A X-Received: by 2002:a05:6a00:9399:b0:6e0:4ea1:951b with SMTP id ka25-20020a056a00939900b006e04ea1951bmr4242pfb.28.1707236598635; Tue, 06 Feb 2024 08:23:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707236598; cv=pass; d=google.com; s=arc-20160816; b=Fhliq3M1swWynOxc1tC4woh5Oh9Krn6WBfqQguHm71vnEHklBHSEjuAOwgmFi2P7fB 155XKMMEPWtBGbSTXQyyLefiT2XwpxHBVGnFAPulPrdunyg7LZqm//iRaSOnY8Y0KMIS xHSDCmwNLbtg47SFGMQioIRRWVls+Kcv9zZtoRRHKe96DOSu6K6BAXenKfuZqDOj7nzn rzhwqrv96F8HgiGDpMYKWX0mdPXsAO+o9JMkQ3OAlmwuevPOJANExYqdI3p7NVZstimi fdvFYR8iXj268raNXe7p7NPPM3CH0OkTaHzcAMmKh7G6RBbuGjfnhbnt1hsmryHaunTu 60lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZxY90mq64nwRlWZ6KSsKAjHQhv0ctq/p0qeuRDVx5rU=; fh=+bxytehxU9iQG3d4LXcpSE75mdt9xUyxWnxeyhC6Cxs=; b=FjV/kev0/dRDt4NyLdmONp7H6jrX7ajbOGZ1IKy0iJ9ss+4Rkd80AshAzw+xhMyFOM Rj6TOnf4A9LpIBz1AkNDXesG4bi50Ai6nF8AKSOp9IW61Q3OdA2tMROmJdSerlwK5JPt qyzHYlXkc+RXPct88ISBzL6Ih7WZtfWoEznX07QgMITi7n5j+K9D/ClIsbOoZz/HuT/j No0cVo7qx2J8PE8HS00RrG/qjcu3laEfbfRcV2ByEGB76y4q99WVpk5xE3bcXJIHLq7N N6DOkPB78rhra6psfdcUmq0glTDFGuYRl4HtLA1cEAJCMzWinqSjM0mPSiI3Uw1U0RfA 9dTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RGy0LUFo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-55066-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55066-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVvOHWXexuDfcJ5OMQnXYzmWQAnoYxA0PF9MKudb6o0Ud9op6Z1kUcms+f/0sTf65U7msV7ff6QLMYGbm3YBMNp8pSLzg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f4-20020a056a00228400b006dbb1f82e81si1929890pfe.170.2024.02.06.08.23.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:23:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55066-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RGy0LUFo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-55066-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55066-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 188A7B22576 for ; Tue, 6 Feb 2024 13:59:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61E821332B0; Tue, 6 Feb 2024 13:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RGy0LUFo" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45EEC131E5A; Tue, 6 Feb 2024 13:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707227890; cv=none; b=fT73swC6xxPiJSmMu0khByrSLP5za3kpj5aZgo7RwXQajl0YBteKL8/zf9L6Isc/6qyDQ66PRjygI0SeHQWVUIIRKBd2LKNmzftSE7nTBJ8q2BMAljhLwXwDPbbFoYAwlaHT9CKkGYDt4NCBD0iG9MvKVbJonMJ/fAhkUc30jZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707227890; c=relaxed/simple; bh=eWVd+iQjSnkkATuBAY8oLrtYHKAXW1b0jt18ycqn0UY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ke2t2knIXSRchAdo98sltZ2R9RYT4pT55hTyxOEPbVUNrQYq+2gfcSfOkieHEmVuP28wBv06ljSXBC729bSmak32SekcFuy1wnTmqZS7n6nuI4/vDK/sEZucyN1UNbwVFmHSSkrbGXVxBRVVmsUDbfNo+oMW/gIAzQbg3PHbJxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RGy0LUFo; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707227889; x=1738763889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eWVd+iQjSnkkATuBAY8oLrtYHKAXW1b0jt18ycqn0UY=; b=RGy0LUFoawE1U5iUPG+XVNljGjTXJwT3j7jLlV+sDul0IceknsxCGZWV FOlyAA78ULx6esvoedyYDkKDVxOWwoRtBegPN+HwsvFwEbslvZYDKkrh7 BwMJl6cu5Z6LiyX9GHcBoz43edFSoOJPvIbzdmeM/7SwwdOj7xDGy8nWg 1Z3VGth64w5+DYapdAiIvz7IFZHOKAXPXlqRydPn4Ck9WYFSCGKm2zcio T45TIyZ9HxP37kayHaCIYSax3C+g512TCWrB7CFlmyimktTIWxlfz5nMz puVm0A9I1csszW9Ci55ekWsLEFmxrpFTUZlV6BlHJJ2iSygQtynWRtCfM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="905272" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="905272" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 05:58:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="1008779" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.36.139]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 05:58:02 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Jesse Brandeburg , intel-wired-lan@lists.osuosl.org, Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mahesh J Salgaonkar , "Oliver O'Halloran" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Ard Biesheuvel , Borislav Petkov , linux-edac@vger.kernel.org, linux-efi@vger.kernel.org, Tony Luck , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 4/4] PCI: Create helper to print TLP Header and Prefix Log Date: Tue, 6 Feb 2024 15:57:17 +0200 Message-Id: <20240206135717.8565-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240206135717.8565-1-ilpo.jarvinen@linux.intel.com> References: <20240206135717.8565-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790167323760027641 X-GMAIL-MSGID: 1790167323760027641 Add pcie_print_tlp_log() helper to print TLP Header and Prefix Log. Print End-End Prefixes only if they are non-zero. Consolidate the few places which currently print TLP using custom formatting. Signed-off-by: Ilpo Järvinen --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +-- drivers/pci/pci.c | 28 +++++++++++++++++++ drivers/pci/pcie/aer.c | 10 ++----- drivers/pci/pcie/dpc.c | 5 +--- include/linux/aer.h | 2 ++ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 6ce720726a1a..73eabf3215e5 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -11355,8 +11355,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, vf = FIELD_GET(0x7F, req_id); e_dev_err("VF %d has caused a PCIe error\n", vf); - e_dev_err("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: %8.8x\tdw3: %8.8x\n", - tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]); + pcie_print_tlp_log(pdev, &tlp_log, ""); + switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: device_id = IXGBE_82599_VF_DEVICE_ID; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 268a5b9f1dff..d7974d25ae44 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -1118,6 +1119,33 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2, } EXPORT_SYMBOL_GPL(pcie_read_tlp_log); +/** + * pcie_print_tlp_log - Print TLP Header / Prefix Log contents + * @dev: PCIe device + * @tlp_log: TLP Log structure + * @pfx: Internal string prefix (for indentation) + * + * Prints TLP Header and Prefix Log information held by @tlp_log. + */ +void pcie_print_tlp_log(const struct pci_dev *dev, + const struct pcie_tlp_log *tlp_log, const char *pfx) +{ + unsigned int i; + + pci_err(dev, "%sTLP Header: %#010x %#010x %#010x %#010x", + pfx, tlp_log->dw[0], tlp_log->dw[1], tlp_log->dw[2], tlp_log->dw[3]); + + if (tlp_log->prefix[0]) + pr_cont(" E-E Prefixes:"); + for (i = 0; i < ARRAY_SIZE(tlp_log->prefix); i++) { + if (!tlp_log->prefix[i]) + break; + pr_cont(" %#010x", tlp_log->prefix[i]); + } + pr_cont("\n"); +} +EXPORT_SYMBOL_GPL(pcie_print_tlp_log); + /** * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) * @dev: PCI device to have its BARs restored diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ecc1dea5a208..efb9e728fe94 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -664,12 +664,6 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, } } -static void __print_tlp_header(struct pci_dev *dev, struct pcie_tlp_log *t) -{ - pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", - t->dw[0], t->dw[1], t->dw[2], t->dw[3]); -} - static void __aer_print_error(struct pci_dev *dev, struct aer_err_info *info) { @@ -724,7 +718,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) __aer_print_error(dev, info); if (info->tlp_header_valid) - __print_tlp_header(dev, &info->tlp); + pcie_print_tlp_log(dev, &info->tlp, " "); out: if (info->id && info->error_dev_num > 1 && info->id == id) @@ -796,7 +790,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, aer->uncor_severity); if (tlp_header_valid) - __print_tlp_header(dev, &aer->header_log); + pcie_print_tlp_log(dev, &aer->header_log, " "); trace_aer_event(dev_name(&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index f384d0b02aa0..9c93871fbe37 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -229,10 +229,7 @@ static void dpc_process_rp_pio_error(struct pci_dev *pdev) pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, dpc_tlp_log_len(pdev), &tlp_log); - pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n", - tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]); - for (i = 0; i < pdev->dpc_rp_log_size - 5; i++) - pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, tlp_log.prefix[i]); + pcie_print_tlp_log(pdev, &tlp_log, ""); if (pdev->dpc_rp_log_size < 5) goto clear_status; diff --git a/include/linux/aer.h b/include/linux/aer.h index 9a8845c01400..210f497e7cdd 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -41,6 +41,8 @@ struct aer_capability_regs { int pcie_read_tlp_log(struct pci_dev *pdev, int where, int where2, unsigned int tlp_len, struct pcie_tlp_log *tlp_log); unsigned int aer_tlp_log_len(struct pci_dev *dev); +void pcie_print_tlp_log(const struct pci_dev *dev, + const struct pcie_tlp_log *tlp_log, const char *pfx); #if defined(CONFIG_PCIEAER) int pci_aer_clear_nonfatal_status(struct pci_dev *dev);