From patchwork Fri Aug 25 10:49:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 110999 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp812723qge; Fri, 25 Aug 2017 03:53:55 -0700 (PDT) X-Received: by 10.28.109.151 with SMTP id b23mr1058936wmi.24.1503658435261; Fri, 25 Aug 2017 03:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503658435; cv=none; d=google.com; s=arc-20160816; b=kU3QGALSClplgPqtrX8lVkVkMdmhL0f/rk63tCm3INMsvX+VFHXrkmUSUaSYdJ8oVJ FU3UzRGRSv0A4KU103KpkFHwmLihpHBVb8zxfN+OdDvGXzzKb/A31Qz2Yr8pzIPzWfAy TwXuSE0ktW/Hj4CALIaXFvBSk4Np+PsCWQEEjZsDbFdTU7/Oe4G2dOMw45yQaG4Snn5g S6dFczHRYtk1rWtwS5zBI36gtH1kyP2Ln5uwg1LI8STc4+UES1cCwrnBuzHJ88ZoAi/N FtTG7+2GUguXVx1SqSOyZsJpTqwvNU0hA+rmBhS6v9oIz/c2Y6xk5CWqHuG8lKGiaO1S q07g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=+Au9nBWwFDFvAZ3JRI3SZBDLtac2vJcp6rvSJfr4uNE=; b=Z88J6AtLou0/MR+/wflbS4ZujyKO151oaFuODYYZh2lRBySnnSHCPQ1az1kWAi7pvs Bsu3mc/Eoogm1voBXT64p9/7UC8ClGHGs3i388jf8lXOX/QcFkc9PTYjMAu97Y6tg6jN LGNmX7AC/mQYfP2TF0qzqvQ+YlCSU4ya2xFioQNRbuOLu5p/SMi2U9M3+khzBnIwTa0Q nY06TcZqos9iLhjTgJ96sxqtZmoJ4m/XZkM3Ngcj0fb4BQiuIMGfC0IB2MYcSflOWLvf bTleY3tYilafq9A3Zg7kQuRiTJbpIEg25/Z2TVvBXsHx9bS51r85LAXSx99J19SSx4Pe ecOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id 35si5068932wrn.335.2017.08.25.03.53.55; Fri, 25 Aug 2017 03:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id CF9AD998A; Fri, 25 Aug 2017 12:50:38 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0045.outbound.protection.outlook.com [104.47.34.45]) by dpdk.org (Postfix) with ESMTP id 895629957 for ; Fri, 25 Aug 2017 12:50:33 +0200 (CEST) Received: from MWHPR03CA0014.namprd03.prod.outlook.com (10.175.133.152) by MWHPR03MB3328.namprd03.prod.outlook.com (10.174.249.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1385.9; Fri, 25 Aug 2017 10:50:31 +0000 Received: from BY2FFO11FD015.protection.gbl (2a01:111:f400:7c0c::100) by MWHPR03CA0014.outlook.office365.com (2603:10b6:300:117::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1362.18 via Frontend Transport; Fri, 25 Aug 2017 10:50:31 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD015.mail.protection.outlook.com (10.1.14.131) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Fri, 25 Aug 2017 10:50:31 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7PAnw6K032070; Fri, 25 Aug 2017 03:50:29 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 25 Aug 2017 16:19:32 +0530 Message-ID: <1503658183-4078-17-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131481318316173680; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(356003)(305945005)(50466002)(104016004)(110136004)(53936002)(36756003)(48376002)(2906002)(6666003)(189998001)(54906002)(85426001)(68736007)(8676002)(498600001)(77096006)(81166006)(86362001)(81156014)(76176999)(105606002)(106466001)(50986999)(5003940100001)(8656003)(8936002)(2950100002)(4326008)(97736004)(47776003)(626005)(33646002)(5660300001)(6916009)(2351001)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB3328; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD015; 1:kw9nj4ubbSJEvQ1XlC2QzbPwr1dT7D9WNBdH7JX2Ul+pOn4Ckc9zuNLuQQrZ3nqIeNpdRj2BSqv4DB4uS2ahSJiqr/OvFyTELoDrLCeOMewMTqA/+sRnh9xdTfE4mzef MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 427a0a2d-8d3e-43e7-de60-08d4eba71b39 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR03MB3328; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB3328; 3:Qb1rM0xCUEIBLFRE2A3GHXnrfr2l+s0rNH+zIfn5nSXZIaJnzsfp9ehUhCSS8TZv9l/4covTU/VVFPXZfw79Ehc+gnTE2nI3TDiGGGJS8LnlNLtl5e0o6ieHcfqQDKQbF1IL+/EXsHEJlbdjB1lg0t7JWLmt2GFxQrgA5aGgyfL2u/9dUNTbXy9mcwlsEqzOThMN7jJ9yseeeVflBTKW46UG1qfdgvXuU/Q9Yzg1RQ/BvXvAf7MjMi3f8jK/EO/P896ca6DnmVY0u4b+q6Xmr2aUcxGP9v/AWg6of5HbG2/eN8y3S4pAu5lHZMHj20yX2JR+JFddZjSYpTsE/q+VT6FsCDpk4LW9L3rGZRYAv1Y=; 25:JzE0p/XFQ6HazSYDx3d562k62LUD8ZN2888QED8VEbYC5D3kU1zYTlsvyK86GPzvnwivqbuREs51tKWWYuaYuSgG2W75bUsWgT8JQjrjEeUEkeNzAix/aSgxpx9BMSD55jVqRmyIP5tEtJUv3kyvYN/t3eKLYx7oeglb0MJ1qitpG2rfAefU8IVjJ+eL/Ksq3/zelsBhN5WrPRu6/4fcCMrsTJWvLIWRwr4t5r7stuYwtHUxPBx6BFZ4otzHih2zSrdOjou6RaRc2LFhBNLDJPVedoFkuDZbmTbAbwt+/Fzi6hCZ41ztQxvV0ZtLS+4zY6eY2s5LFibqZVbhJQFH0w== X-MS-TrafficTypeDiagnostic: MWHPR03MB3328: X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB3328; 31:PWxaklhFJ881Zz+MWow0kLSz+6rmsFX3SYi3cNqFpagKxmKEiQ3dxKIys4j4LKWTlTwGeFmHIb37jgKx6E8NLim/JzJtpR1z+awUYPIKhRIiCt9Q0vatiQYRJ2Myk1Cgqv9Fx8+ZN+qlSUn0apLBMG4ddex2tr4XhHg6R30hw3QacvMWzczkFrX/x7B6lPzYMjZkF34zF7g2KuFj3xQLksQGZUghq4M6q+YffdobvaI=; 4:v/Jat5FaptwyRSSlRkIFmLmh10uV+Eqgrlk+AfP0B7njbo87dAGF3m8gifGvEeFY0mYyB0EXzmOZbIT9B5v04BA7LBJPsb6T52icHf40ni98Vu/HWuThVa5T6OjYXfX1/Sdp3vZwtNAvI+vhJGkZrkmL96yCjUKGnZiYXwwMfGU4F5ur+SUcK9jofTUV8YxfDpVFrMSCNzjDwHonGJlX/IvX52e9IsDke7fhn30ALFW0wB8OFaS7SxhBADUwIrmSBkhQ2ZnqHgEhQrZ/0AAUWAgWNJgTyOCZtmn5fEVWBS3YcHSkmD1SYLwR3DRYmsBoec5bOqAO51UltjKdYDRNcg== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(13018025)(8121501046)(13016025)(5005006)(3002001)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123556025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123561025)(20161123563025)(20161123559100)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR03MB3328; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR03MB3328; X-Forefront-PRVS: 041032FF37 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB3328; 23:oboN9OWuVw7PJxx/SFG/e7FUIuqy4XRD8iZps3xSy?= k2KhG8FHE4HKPivsQqXzKlZJSwG9cUOXAiUO3XYWPboRKzvitwomXJyB4BVuc6+PCOrnKb1fZk9Cun+jbMGlUz3G/XT8sJUb6Cg/Fkgz6rvDZQ1SPWeGLQxiaJkOCyh4eI7EbFAmgzoS0RnHzbGS5HHCirh9eQUeJs/Y7OZUf9olVhIOjqlE7ca1baGvST9FSDxdY/onc/+69CXCYNyBZMTZ9Wq1Sl+AbpkD+3QewK59/bgFLufv8ZTs0InZsO4uPFkfvHEBQie3hvSpLB9m5AkYlAC3Wl3efadyxE5cqD5qVbn2z1X7K0G2V3B5hm3PeKs2u95RBbPZBDVBuiO5LrKkdrE6rWNvjuay5P39hmh+wUfV6VMLUQzbXchBOKVF4hESZZKi0U8DtIr6cmojC9lEYzXcpEgRObVFun99fBe4S/GaujY4misRqs+Bje4yydwaEDL8WbW4qYx50rLdr4bytwLJQo6WUGDj1yLmM8J5WDI8MITeTLnuiv2iEHu89fTNq+XWpKkkz0p9ovoax1Tf8/bmwgulWf9HkHlrCImrSzQZWCR9CIRtqGUglKEHIABVKdMNU9e2wm8ewv3DCWqVT7G7vciKz1NtREYasgGBirHxVrUdGqLk7O9JdFUDDt0VJ5u6oJClZnYcnOBS3VWXFIBlFOgrpnR7e530DBYX5ZDpgmkj+yuwwnGYv3kASKhB6f/iaTruSwBISeHvjoPzNC/uEDHiXG5N8WiHhvdBzcR0jedXTUPQOCxqta70X3ri8rdmVXAiTnnkSHdQWu2+8Gfks7u+PiJrLJeIA+MIAYJxIznkMmKBgh2HtpblxUaWs7RubfMJpk+gDD78ghd6qMfsmVuwgwRYtyZ06v05+2rJWOKe9fLvhhPbe597eRr+0qyhkizZwM2/pRsoSU5XM2d6SBjJjbXZok915HnQTYqUHkp7qtYegK7aZ4VpoTjguIt9boU0kEtq17+3nPUkKsPviOODPIIfuK7mjWpCXxd9y2cMdyd37uBvDNNwzyvME9wCKKOT7p0zEEcDfURufqMwob7f4B0nY08jJM2EC6H9gGWxOhn4JP3oquNPW55GGLTeEnRjR4nuhlNYsDo X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB3328; 6:ek1uh6p+4WD6cZ4VvKgzI99Pl/BJJTfLTZgGnnM/sqlAth/7b9KgKCsqbz/BCDdlGADXBfQai+SghRc/7sikcjA4+Upyg6pmkXVVrDfOjbEDlp9KYSsDSnU3qGVzMILn+fcroYp+egzFZwoikjmY4Cke8Vx0tg++Ci1OHlMLKLGchrQbak1AyoRflORd4R/vWY23A3tOoCLjhVjG2oioiSFKnfkNwiVmm9K+RC8pL8Ikn2dQFJCB+yIdYdPVYOdRB0h2lxc67NTL7/M3YFVV0BaWrJcaorpo1Zn5DsoXRxtWaCeJPD90qFKUneonOnSN87R0EJOPNPuGCXpU7FxlRQ==; 5:dn61d7cKn2HackCGjzsUtusqx0PmvR9b8DZQl7mqooC+Y3HWoeBPrfn6uSI0MUzJDjzR4gJKeoytwj4XPScZ9LaHKCBmyy17YpmKwgNsFHAg4DGw6Reu4tRAmiUbQ4Ik2iigM4GT+0NeKgKaxoUZmg==; 24:xkEuRIjs17J1LPlQuXDs+aVwnqSoJcNgFeZcHfLwwMTCxL4ZEFQWsZeyFlrPH1D6RA0umOiZtLOnUAkq2ym17Ts00si52TOELlZLsH5JwsY=; 7:4ghinVgkJrcpz6ZFwNc5T/TpsBpzgqPjnSWskfuUZqzeatQXgWZj83w7wut74YqvJ7+ER+K7Sdq7JUDVbu35yIpp0uS+pA/JxgN+SeCrGPuHhub38DhlnEJD9EUYZMhfCvKt3WfnEpfOMRVqL7HYEwzVRIsnMgpUKSXGpOdJ/0lmoacxh6+WHS5kd1UsnjDv5zkWbtGJ4Dn0vRgv9KP3L8cjsFg1Sy0GYFpjNf8UnQA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 10:50:31.3053 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3328 Subject: [dpdk-dev] [PATCH 16/27] bus/fslmc: cleanup the dpaa2 interrupt support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/Makefile | 1 + drivers/bus/fslmc/fslmc_vfio.c | 108 +++++++++++++++++++++++----- drivers/bus/fslmc/fslmc_vfio.h | 8 ++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 18 +++-- drivers/bus/fslmc/rte_bus_fslmc_version.map | 2 + 5 files changed, 110 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/drivers/bus/fslmc/Makefile b/drivers/bus/fslmc/Makefile index d1b790b..37da1b0 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -51,6 +51,7 @@ CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/qbman/include CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common # versioning export map EXPORT_MAP := rte_bus_fslmc_version.map diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index cdc982b..ab1df36 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -335,36 +336,107 @@ static int64_t vfio_map_mcp_obj(struct fslmc_vfio_group *group, char *mcp_obj) #define IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + sizeof(int)) -int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, - uint32_t index) +int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index) { - struct vfio_irq_set *irq_set; + int len, ret; char irq_set_buf[IRQ_SET_BUF_LEN]; - int *fd_ptr, fd, ret; + struct vfio_irq_set *irq_set; + int *fd_ptr; + + len = sizeof(irq_set_buf); - /* Prepare vfio_irq_set structure and SET the IRQ in VFIO */ - /* Give the eventfd to VFIO */ - fd = eventfd(0, 0); irq_set = (struct vfio_irq_set *)irq_set_buf; - irq_set->argsz = sizeof(irq_set_buf); + irq_set->argsz = len; irq_set->count = 1; - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | - VFIO_IRQ_SET_ACTION_TRIGGER; + irq_set->flags = + VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; irq_set->index = index; irq_set->start = 0; fd_ptr = (int *)&irq_set->data; - *fd_ptr = fd; + *fd_ptr = intr_handle->fd; ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); - if (ret < 0) { - FSLMC_VFIO_LOG(ERR, "Unable to set IRQ in VFIO, ret: %d\n", - ret); - return -1; + if (ret) { + RTE_LOG(ERR, EAL, "Error:dpaa2 SET IRQs fd=%d, err = %d(%s)\n", + intr_handle->fd, errno, strerror(errno)); + return ret; } - /* Set the FD and update the flags */ - intr_handle->fd = fd; - return 0; + return ret; +} + +int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index) +{ + struct vfio_irq_set *irq_set; + char irq_set_buf[IRQ_SET_BUF_LEN]; + int len, ret; + + len = sizeof(struct vfio_irq_set); + + irq_set = (struct vfio_irq_set *)irq_set_buf; + irq_set->argsz = len; + irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER; + irq_set->index = index; + irq_set->start = 0; + irq_set->count = 0; + + ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); + if (ret) + RTE_LOG(ERR, EAL, + "Error disabling dpaa2 interrupts for fd %d\n", + intr_handle->fd); + + return ret; +} + +/* set up interrupt support (but not enable interrupts) */ +int +rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle, + int vfio_dev_fd, + int num_irqs) +{ + int i, ret; + + /* start from MSI-X interrupt type */ + for (i = 0; i < num_irqs; i++) { + struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) }; + int fd = -1; + + irq_info.index = i; + + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info); + if (ret < 0) { + FSLMC_VFIO_LOG(ERR, + "cannot get IRQ(%d) info, error %i (%s)", + i, errno, strerror(errno)); + return -1; + } + + /* if this vector cannot be used with eventfd, + * fail if we explicitly + * specified interrupt type, otherwise continue + */ + if ((irq_info.flags & VFIO_IRQ_INFO_EVENTFD) == 0) + continue; + + /* set up an eventfd for interrupts */ + fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); + if (fd < 0) { + FSLMC_VFIO_LOG(ERR, + "cannot set up eventfd, error %i (%s)\n", + errno, strerror(errno)); + return -1; + } + + intr_handle->fd = fd; + intr_handle->type = RTE_INTR_HANDLE_VFIO_MSI; + intr_handle->vfio_dev_fd = vfio_dev_fd; + + return 0; + } + + /* if we're here, we haven't found a suitable interrupt vector */ + return -1; } /* diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h index edb86d0..5470a41 100644 --- a/drivers/bus/fslmc/fslmc_vfio.h +++ b/drivers/bus/fslmc/fslmc_vfio.h @@ -64,8 +64,12 @@ typedef struct fslmc_vfio_container { struct fslmc_vfio_group *group; } fslmc_vfio_container; -int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, - uint32_t index); +int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index); +int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index); + +int rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle, + int vfio_dev_fd, + int num_irqs); int fslmc_vfio_setup_group(void); int fslmc_vfio_process_group(void); diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c index 8db1f6c..ff41ce4 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c @@ -440,7 +440,6 @@ dpaa2_create_dpio_device(int vdev_fd, { struct dpaa2_dpio_dev *dpio_dev; struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)}; - int vfio_dev_fd; if (obj_info->num_regions < NUM_DPIO_REGIONS) { PMD_INIT_LOG(ERR, "ERROR, Not sufficient number " @@ -457,14 +456,12 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->dpio = NULL; dpio_dev->hw_id = object_id; - dpio_dev->intr_handle.vfio_dev_fd = vdev_fd; rte_atomic16_init(&dpio_dev->ref_count); /* Using single portal for all devices */ dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX]; reg_info.index = 0; - vfio_dev_fd = dpio_dev->intr_handle.vfio_dev_fd; - if (ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) { + if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) { PMD_INIT_LOG(ERR, "vfio: error getting region info\n"); rte_free(dpio_dev); return -1; @@ -473,10 +470,10 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->ce_size = reg_info.size; dpio_dev->qbman_portal_ce_paddr = (uint64_t)mmap(NULL, reg_info.size, PROT_WRITE | PROT_READ, MAP_SHARED, - vfio_dev_fd, reg_info.offset); + vdev_fd, reg_info.offset); reg_info.index = 1; - if (ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) { + if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) { PMD_INIT_LOG(ERR, "vfio: error getting region info\n"); rte_free(dpio_dev); return -1; @@ -485,7 +482,7 @@ dpaa2_create_dpio_device(int vdev_fd, dpio_dev->ci_size = reg_info.size; dpio_dev->qbman_portal_ci_paddr = (uint64_t)mmap(NULL, reg_info.size, PROT_WRITE | PROT_READ, MAP_SHARED, - vfio_dev_fd, reg_info.offset); + vdev_fd, reg_info.offset); if (configure_dpio_qbman_swp(dpio_dev)) { PMD_INIT_LOG(ERR, @@ -497,6 +494,13 @@ dpaa2_create_dpio_device(int vdev_fd, io_space_count++; dpio_dev->index = io_space_count; + + if (rte_dpaa2_vfio_setup_intr(&dpio_dev->intr_handle, vdev_fd, 1)) { + PMD_INIT_LOG(ERR, "Fail to setup interrupt for %d\n", + dpio_dev->hw_id); + rte_free(dpio_dev); + } + TAILQ_INSERT_TAIL(&dpio_dev_list, dpio_dev, next); PMD_INIT_LOG(DEBUG, "DPAA2: Added [dpio.%d]", object_id); diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map index 7b25248..51a2ac6 100644 --- a/drivers/bus/fslmc/rte_bus_fslmc_version.map +++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map @@ -85,5 +85,7 @@ DPDK_17.11 { dpaa2_dpbp_supported; rte_dpaa2_dev_type; + rte_dpaa2_intr_disable; + rte_dpaa2_intr_enable; } DPDK_17.08;