Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3307084imm; Tue, 17 Jul 2018 02:32:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfTyybuH/pis4bPcswoaKKB1dZ8GYd906SOtOA4tcbe/JBC+UGi/qvKw8s8UXtkKjqWQJtj X-Received: by 2002:a65:6343:: with SMTP id p3-v6mr904466pgv.48.1531819962815; Tue, 17 Jul 2018 02:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531819962; cv=none; d=google.com; s=arc-20160816; b=EcKSzaCNaGe6voKOmWmI4qqhZKhT9hItvh1zcbN6Ffkc6Lv2lCLuPdNZ9Fc/oOGauZ Y59kJzzCc6qkQIJ/zNCsME9/TFHeXPxfoh7l7x12CXXU2PTvv0xaBloOE7mCDOBDgBUs XdlJz9ENl8Vb4GTDQedq2qyCQkR0Nc00AAIXMbHNGtwknfz6jEkMIN1WQR5D9kQjBKCK yJCCziPtKYauXDNsieGyOvrJWto+d+w+YjCTnkpSl6gdurjChMqARgriJ8eXLi8VHvhf sA1gftkik7/8iuhBw14nqiikDx+ry0NoReixrjBvCffZl5ZcjbEz8JdKHcqgSwZI4Ujh RpJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=m+sm8/msM/k4B04A1I3GTFjld6yM9VTpl/rEBTVG44E=; b=MvgLN5qtI0Q73kjjgb2P8kV7Fyhhjs2JhuczQIokun7Fes7013EDuISctsHYWmEZvM GbBebgqQBADbPCPSHCmMfzvqWeJ1Q4bmcsv+qZ8I/IVMHA30PrSOzzsxJFMZnvsPK0wI 1R8fEyij21udlx506rqlBh1DLhwFjbNMxjFVxOO0HZoqiukZFoXChmQWacHOVHTBlghZ 5lRC+NxiN3vFOw/92R9NrAyTqKpuTKE292/U4+38pAhM76iBzk3GJHsRmzv0GwHFumsZ wOg79gqqOvPdKP/jcYTTmmPDwaIF0EHzaPo3Ou2efKeVE/0IzeWNBXgsmKwiqy40/zEj I4SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=SdgASmhe; 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=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26-v6si473406pgb.571.2018.07.17.02.32.27; Tue, 17 Jul 2018 02:32:42 -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=@synopsys.com header.s=mail header.b=SdgASmhe; 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=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730839AbeGQKDT (ORCPT + 99 others); Tue, 17 Jul 2018 06:03:19 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:59880 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730123AbeGQKDS (ORCPT ); Tue, 17 Jul 2018 06:03:18 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id E566024E0762; Tue, 17 Jul 2018 02:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1531819896; bh=RX1UUV3Uv74b3n8WRaby7Cw/fcc88erhc4ieU+hqRA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=SdgASmhezUazOY9CuOarMMPe429UDTB467Zg2ySOeYxtRzXQkAF4ATCCqUnJU406Z ZiI0QnXqVcOm/K0TyZMDVXfO+ZCcA7Q6lkXOV46LOBrgITIA7y12CKrpOQppg+0Buj KqiUSEfTcnDKJQVwxmV4W9VoIMpghzmkDPJb0Bcz4ddvHnh3k1IYG9Mq91euLPAPrt 35RBWygnk/0iDe05FNYk+KvrAoKcnn4lRwdKwvocTSshcZKDvukdi0WlF3R6O/QD1n dlhTwP4mR2DlGlUs7qcZ6bYIRBU2XLmoG9F3F7VJENf1VBageLaD3q4vE6rZjDTtOV tFO0T4V/JMtpQ== Received: from de02.synopsys.com (de02.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 9A8803FB6; Tue, 17 Jul 2018 02:31:36 -0700 (PDT) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id B24793BC22; Tue, 17 Jul 2018 11:31:34 +0200 (CEST) From: Gustavo Pimentel To: bhelgaas@google.com, lorenzo.pieralisi@arm.com, joao.pinto@synopsys.com, jingoohan1@gmail.com, kishon@ti.com, adouglas@cadence.com, jesper.nilsson@axis.com, shawn.lin@rock-chips.com Cc: linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Gustavo Pimentel Subject: [PATCH v12 11/12] tools: PCI: Add MSI-X support Date: Tue, 17 Jul 2018 11:31:31 +0200 Message-Id: <54f46aa3181cb1a34983ba72fcda02251f93baf2.1531818979.git.gustavo.pimentel@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add MSI-X support to pcitest tool. Modify pcitest.sh script to accommodate MSI-X interrupt tests. Update documentation accordingly. Signed-off-by: Gustavo Pimentel Acked-by: Kishon Vijay Abraham I --- Change v1->v2: - Allow IRQ type driver reconfiguring in runtime, follwing Kishon's suggestion. Change v2->v3: - Nothing changed, just to follow the patch set version. Change v3->v4: - Rebased to Lorenzo's master branch v4.18-rc1. Change v4->v5: - Nothing changed, just to follow the patch set version. Change v5->v6: - Moved PCITEST_MSIX ioctl entry to patch #8. - Moved PCITEST_SET_IRQTYPE and PCITEST_GET_IRQTYPE ioctl entries to patch #9. Change v6->v7: - Nothing changed, just to follow the patch set version. Change v7->v8: - Re-sending the patch series. Change v8->v9: - Nothing changed, just to follow the patch set version. Change v9->v10: - Updated documentation. Change v10->v11: - Nothing changed, just to follow the patch set version. Change v11->v12: - Nothing changed, just to follow the patch set version. Documentation/PCI/endpoint/pci-test-howto.txt | 36 +++++++++++-------- tools/pci/pcitest.c | 51 ++++++++++++++++++++++++++- tools/pci/pcitest.sh | 15 ++++++++ 3 files changed, 87 insertions(+), 15 deletions(-) diff --git a/Documentation/PCI/endpoint/pci-test-howto.txt b/Documentation/PCI/endpoint/pci-test-howto.txt index 65f1a13..e40cf0f 100644 --- a/Documentation/PCI/endpoint/pci-test-howto.txt +++ b/Documentation/PCI/endpoint/pci-test-howto.txt @@ -121,7 +121,9 @@ following commands. Interrupt tests + SET IRQ TYPE TO LEGACY: OKAY LEGACY IRQ: NOT OKAY + SET IRQ TYPE TO MSI: OKAY MSI1: OKAY MSI2: OKAY MSI3: OKAY @@ -154,24 +156,30 @@ following commands. MSI30: NOT OKAY MSI31: NOT OKAY MSI32: NOT OKAY - MSIX1: OKAY - MSIX2: OKAY - MSIX3: OKAY - MSIX4: OKAY - MSIX5: OKAY - MSIX6: OKAY - MSIX7: OKAY - MSIX8: OKAY - MSIX9: NOT OKAY - MSIX10: NOT OKAY - MSIX11: NOT OKAY - MSIX12: NOT OKAY - MSIX13: NOT OKAY + SET IRQ TYPE TO MSI-X: OKAY + MSI-X1: OKAY + MSI-X2: OKAY + MSI-X3: OKAY + MSI-X4: OKAY + MSI-X5: OKAY + MSI-X6: OKAY + MSI-X7: OKAY + MSI-X8: OKAY + MSI-X9: NOT OKAY + MSI-X10: NOT OKAY + MSI-X11: NOT OKAY + MSI-X12: NOT OKAY + MSI-X13: NOT OKAY + MSI-X14: NOT OKAY + MSI-X15: NOT OKAY + MSI-X16: NOT OKAY [...] - MSIX2048: NOT OKAY + MSI-X2047: NOT OKAY + MSI-X2048: NOT OKAY Read Tests + SET IRQ TYPE TO MSI: OKAY READ ( 1 bytes): OKAY READ ( 1024 bytes): OKAY READ ( 1025 bytes): OKAY diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 9074b47..af146bb 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -31,12 +31,17 @@ #define BILLION 1E9 static char *result[] = { "NOT OKAY", "OKAY" }; +static char *irq[] = { "LEGACY", "MSI", "MSI-X" }; struct pci_test { char *device; char barnum; bool legacyirq; unsigned int msinum; + unsigned int msixnum; + int irqtype; + bool set_irqtype; + bool get_irqtype; bool read; bool write; bool copy; @@ -65,6 +70,24 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } + if (test->set_irqtype) { + ret = ioctl(fd, PCITEST_SET_IRQTYPE, test->irqtype); + fprintf(stdout, "SET IRQ TYPE TO %s:\t\t", irq[test->irqtype]); + if (ret < 0) + fprintf(stdout, "FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + + if (test->get_irqtype) { + ret = ioctl(fd, PCITEST_GET_IRQTYPE); + fprintf(stdout, "GET IRQ TYPE:\t\t"); + if (ret < 0) + fprintf(stdout, "FAILED\n"); + else + fprintf(stdout, "%s\n", irq[ret]); + } + if (test->legacyirq) { ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0); fprintf(stdout, "LEGACY IRQ:\t"); @@ -83,6 +106,15 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } + if (test->msixnum > 0 && test->msixnum <= 2048) { + ret = ioctl(fd, PCITEST_MSIX, test->msixnum); + fprintf(stdout, "MSI-X%d:\t\t", test->msixnum); + if (ret < 0) + fprintf(stdout, "TEST FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + if (test->write) { ret = ioctl(fd, PCITEST_WRITE, test->size); fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size); @@ -133,7 +165,7 @@ int main(int argc, char **argv) /* set default endpoint device */ test->device = "/dev/pci-endpoint-test.0"; - while ((c = getopt(argc, argv, "D:b:m:lrwcs:")) != EOF) + while ((c = getopt(argc, argv, "D:b:m:x:i:Ilrwcs:")) != EOF) switch (c) { case 'D': test->device = optarg; @@ -151,6 +183,20 @@ int main(int argc, char **argv) if (test->msinum < 1 || test->msinum > 32) goto usage; continue; + case 'x': + test->msixnum = atoi(optarg); + if (test->msixnum < 1 || test->msixnum > 2048) + goto usage; + continue; + case 'i': + test->irqtype = atoi(optarg); + if (test->irqtype < 0 || test->irqtype > 2) + goto usage; + test->set_irqtype = true; + continue; + case 'I': + test->get_irqtype = true; + continue; case 'r': test->read = true; continue; @@ -173,6 +219,9 @@ int main(int argc, char **argv) "\t-D PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n" "\t-b BAR test (bar number between 0..5)\n" "\t-m MSI test (msi number between 1..32)\n" + "\t-x \tMSI-X test (msix number between 1..2048)\n" + "\t-i \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n" + "\t-I Get current IRQ type configured\n" "\t-l Legacy IRQ test\n" "\t-r Read buffer test\n" "\t-w Write buffer test\n" diff --git a/tools/pci/pcitest.sh b/tools/pci/pcitest.sh index 77e8c85..75ed48f 100644 --- a/tools/pci/pcitest.sh +++ b/tools/pci/pcitest.sh @@ -16,7 +16,10 @@ echo echo "Interrupt tests" echo +pcitest -i 0 pcitest -l + +pcitest -i 1 msi=1 while [ $msi -lt 33 ] @@ -26,9 +29,21 @@ do done echo +pcitest -i 2 +msix=1 + +while [ $msix -lt 2049 ] +do + pcitest -x $msix + msix=`expr $msix + 1` +done +echo + echo "Read Tests" echo +pcitest -i 1 + pcitest -r -s 1 pcitest -r -s 1024 pcitest -r -s 1025 -- 2.7.4