Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1929293imm; Fri, 6 Jul 2018 08:54:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLwCOiHO5b9rXSm6VDDzjE65EbnX70zhru7VTrFkN5v0/2UqTXIAd7B6WL983SVoBUIYqF X-Received: by 2002:a65:64c6:: with SMTP id t6-v6mr9926732pgv.223.1530892490470; Fri, 06 Jul 2018 08:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530892490; cv=none; d=google.com; s=arc-20160816; b=PSxWsgV5a8uMgCqvDAqkU8tIfey3fxzO9pW8YuUf0I0QN+0r9A9KDJvlCmA2O28oD0 ImLFifvgfuUL9RKdhoDHp3HXTjUMVaSKfzhsh6BMhwCkDbbCe5ZI3Zc2EV3pIAyKYDwn vSnfZNc4ad9Vw8DUWC8R1xkFjouFPn9bdEC07Az+zfl8gzohjzCgmQcQKlogZlBfW1rk 1EVfX3rbnbwJTWZvHXQFQXLZQlMc4Lu52v3D/mocVlF8/Cgvj0q0pFRxyKYRWbM3PzJa GH3Q4yduTYHqhIe3YCLIVSwew0aiYDg9xEgJiLkTeIkPQqGCgTr5AKSALyWiyh1ZCdhz W9/Q== 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=rGMGIbwW4zvqiPf/u+Xrn/KaJ19ido52AKKkUQPk0+8=; b=mpUYcJR87lYmJn5F0AIydepdGH41VNFbccH4pJisV/+ev2p5GTa6M/Canyp8wMBvcb tN+Kioe3T2FT2WGHQ+z9HOcZeI2uejpdAPm5vaMAMk6qtvVKZ6HhaZHz0FaWKug03qdk Y+Y6KrTRjD86pAEoPv/QZG9PoJ2z2xm7a6nIG/Soli+GH1qp3ODlTM5NkhAah/6QWATJ i2Gz1n8KE5Xt9PKl1KbNuYenKhNnRkQQz8PGR29OmsMoKGkAXNjN1RwhgP/MglwUC0M8 5L4kuO7hJbkqsU5+qepYtYYt7MN+qAedSLEdTAl+ZGDJzSgMaUkuksY1HKNFaf/PPKA6 KT0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=Ai6pR2QU; 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 6-v6si8273288pgw.680.2018.07.06.08.54.36; Fri, 06 Jul 2018 08:54:50 -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=Ai6pR2QU; 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 S933775AbeGFPxh (ORCPT + 99 others); Fri, 6 Jul 2018 11:53:37 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:40277 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933042AbeGFPvl (ORCPT ); Fri, 6 Jul 2018 11:51:41 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 332C610C0FC3; Fri, 6 Jul 2018 08:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1530892301; bh=Oue71yxglb72PwWuGyegnOAEgeswQ19YJnPJ3Qt1RYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=Ai6pR2QU7sixhV0qBeQS8NrS/X8H6e0IwgRLHGL0s2Uxe6tC5LQJFX22Ogz25JKPq sPN8J/V5eq3Ribtz+gGRhN7FBo4+Xi/ZZ7eJPv3p9+92HpaXD9TNh4snpeFH7L6CSt ia9PfddggsnZwk9WAg5KRVnvIDCoalEeSFO2TvcAJVspM2h1nsuXvZw4BD12ZT3RHS wB2euZQptTcx6bE+OFLYCBCj8We20brpMlBW8BXzZFiUVNBdg72+BU7OJ4R80tljvj mPqB+XzkjNImxWcMX/AuYAiv/ozt9a72ajZ5XvrTpJP2/wCyxqq/QUJP5TnouMRSlz S9X0SvBoNzuPg== Received: from pt02.synopsys.com (pt02.internal.synopsys.com [10.107.23.240]) by mailhost.synopsys.com (Postfix) with ESMTP id D86F134D9; Fri, 6 Jul 2018 08:51:40 -0700 (PDT) Received: from UbuntuMate-64Bits.internal.synopsys.com (gustavo-e7480.internal.synopsys.com [10.107.25.102]) by pt02.synopsys.com (Postfix) with ESMTP id 51D013D25C; Fri, 6 Jul 2018 16:51:39 +0100 (WEST) 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 v8 10/11] tools: PCI: Add MSI-X support Date: Fri, 6 Jul 2018 16:51:33 +0100 Message-Id: <31fa0cf6e75bad9656bd15116688f59abe2a9117.1530891871.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. 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. tools/pci/pcitest.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- tools/pci/pcitest.sh | 15 +++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) 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