From patchwork Sat Sep 16 10:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 112795 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1616288qgf; Sat, 16 Sep 2017 03:56:12 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAjbzaezmfjagdVXEOFxdDz2XxwK7Lm9fDZunvJoYMxXJFKpJ9xt83ysKlfLokIMtOx3sJ1 X-Received: by 10.28.141.18 with SMTP id p18mr4531661wmd.80.1505559372493; Sat, 16 Sep 2017 03:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505559372; cv=none; d=google.com; s=arc-20160816; b=QNKB2mRP1ChboK7naAI0zA/DEJ3H5IT5SVciUIjMcwH8ZJt+/D5EQ0VAuhR6828JKT 3/zmGgEqc1x3q2rCY8pQzqNhAsXP+lJaaDouOl08MjAuHIxD8UZqVETvPX4z+Ml+iFnT bcz1Yum3rO8HTTcAhecT9XpSjsgQATebFoW+HQtb77q2YnTUPldggeqxzM1BLh3SL6C1 xeAwFsPFky/2SnRq53haH07hi1rtPsQmGpt8nVdLQQcaPWbWPBHI7JnQMl2wBrcvDgmy 9q6/MMslae5pSANobSeF1gfN3OwZUOwvCp/Jo8xtT7vlFOzz8w7+Nk/OAMQQDJxZVOoL kCXQ== 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=o9SSuFG2jQUF1VEBKHI0OtKv/RhwJoWGu0yki931vVU=; b=aje8w2fxS6FJLBifj7niqB0NFWTj6kF5rdBo95IKrtWTNSKD+YjU4E3ghl67xWT4X2 vdNZUHFfZjPwEPNArwKNBQhcWhhBDpukIbywhcaeZmJhpuFY3Z/WYlK2wd4N0oAN1IXV UYvf8KG6TI4cKChsUkh9YTxBd4iw5Mr02+1XVPeRZTnunZjHvaxQ9oa36G0qS58ZbhsI LfxZRhSqzyoCKM2GHY/lAzyBOwkKBguwNKXadmSQaaIU7Dg6tW1nSDUdHw+naubqAtnX r7EhfLCUzHlSwSKKq8BK0OKJ0+xK2LkCFO4hpoTG1PYY4wt8v3h0+8P4ZPhdlO3YZAMK lVPw== 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 n17si2487461wrg.297.2017.09.16.03.56.12; Sat, 16 Sep 2017 03:56:12 -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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50F7C1B209; Sat, 16 Sep 2017 12:53:44 +0200 (CEST) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0047.outbound.protection.outlook.com [104.47.32.47]) by dpdk.org (Postfix) with ESMTP id E8BEB1B1BC for ; Sat, 16 Sep 2017 12:53:34 +0200 (CEST) Received: from BN6PR03CA0023.namprd03.prod.outlook.com (2603:10b6:404:23::33) by SN2PR03MB2366.namprd03.prod.outlook.com (2603:10b6:804:e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.9; Sat, 16 Sep 2017 10:53:33 +0000 Received: from BL2FFO11FD034.protection.gbl (2a01:111:f400:7c09::171) by BN6PR03CA0023.outlook.office365.com (2603:10b6:404:23::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11 via Frontend Transport; Sat, 16 Sep 2017 10:53:33 +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 BL2FFO11FD034.mail.protection.outlook.com (10.173.161.130) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.13.11 via Frontend Transport; Sat, 16 Sep 2017 10:53:32 +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 v8GAr6v0028328; Sat, 16 Sep 2017 03:53:31 -0700 From: Hemant Agrawal To: CC: , Date: Sat, 16 Sep 2017 16:22:27 +0530 Message-ID: <1505559161-29222-14-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505559161-29222-1-git-send-email-hemant.agrawal@nxp.com> References: <1504860327-18451-1-git-send-email-hemant.agrawal@nxp.com> <1505559161-29222-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131500328126223019; (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)(376002)(346002)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(8676002)(5660300001)(50986999)(97736004)(85426001)(76176999)(81156014)(53936002)(77096006)(68736007)(54906002)(81166006)(5003940100001)(305945005)(104016004)(47776003)(106466001)(50226002)(2351001)(110136004)(8936002)(105606002)(4326008)(2950100002)(498600001)(86362001)(356003)(189998001)(33646002)(2906002)(50466002)(48376002)(36756003)(316002)(6666003)(6916009)(8656003)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2366; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD034; 1:XUuIVMjO8Fb299bxRLcunZaR5f03W6Sxvegkd1YECJi9uFaOTijPlEaihIbLALWDqoTDGVJp+g7AIEOa5Jf7eu3KawoCEklL05poMiRzw58IWRPsXPJI6abIhW9F+GAm MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9daa2bb-b0c6-4868-314a-08d4fcf12c44 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:SN2PR03MB2366; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2366; 3:C6H6ClUXr450oRhgyomxIPt4jM0ef8p0VJm5TLELlz4JhfqTPFJsYaihb+LmKLKXvicCYwrO1tuU8widIEJg2b0YA4gTB8TantQFcKIZXrB/3SWc5F7haLUmWs/ulWsXtEr74/t56EZ9l6+aW1tP76xyX8jJwTqekvliaLE0BxlLWl3vlBGsI9HkhDUjPlJO2//KxH4C49l3NhKs8HQ1Ppnfb8QT2sgOTjo8TcsRZvbMEUIWCOmjHvTdG4yJ1cvTqr4/crvwHv00Ad6nVogwt1ZphqfW6bn86k0YWzNFwrvnfN0aVPna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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)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123556025)(20161123563025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR03MB2366; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR03MB2366; X-Forefront-PRVS: 0432A04947 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2366; 23:1aKeUx54yM8jIHnxq6DbdcBIo6kLN0z1aSn9DGler?= 39MWodLlvqVp5ED9UNeydeQaWcv7J6eNd1pB+q3xdW6RL0KdHoP6spp0Vxk6W9jJ+0+aeGLTOymsiUUTVpGL08Ks826rXpMeFZSvoUAmm022w/YEl7BNFgyYA/8ae0E0LUl3ey0ozplHvlTI+c5s85A5hlNT5MtjKvvue+utVa0VZFyhddI0QUWbZ+8sfaLC5qKWAuB86Yk5KYRLMP9bYY5LptcWCDbr1QRsjmL0E2aaKyUx57iea93Rdl/h7gD//Bi0BnCk40+HEXm1IV/0Vz5hbv6wacZEPM4zDUZC/u+pv6vagDgvlKVzu6cUJ5Y3Ak3JAkb+vJJ7vhBgsHXSRKVY16tPot8kW0mrwh1zGy7zxx0wsdNiM1eWAXFGN3V7gENzxvCKNds3/Wua+RInmdYdOoCejGxx3l3mAlQxq+JsLKxM1EGZ0WyvzKkA+0A8Tz2k6jicgbJx854eSCa15eUw67yHd/tUjfBTUwhrNORXMntjnT0d2y85UVDWFAZNYIBGXqvWleGJ8xirR33NG+VfVI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O4FU+JY5ZW8Dcj9RkTbJyHx3lcyi6HdDXJFdnf+yOiX2Ynzyyq09kqM2LwUjgflFKMd4dzU7BhihkbE7b8KiOhDZkdQWDesL8VBjM=; 24:8QORTR2srR+1w/Jtti4qk0piczRiporhEckDCFSTvEktGlTXWVT4pr378+CtZbsFdz1SHWkF78S3XVOWIsREsOQihNbcVtUHV7DVjRefuGc=; 7:+gu2Hr+Maij05V23mgP87Ruy1IRug+/qZwb3v7XTnQ0hWYOLmSfGgrAkHB20YMyZCnMvNcMC2PpVzqB9YuM3yHriVp7I+J8VTJXFRhXmpmqrQ0XHv3b3g7nQ4zugMFCGElA4dCY3MDppldpZ6oHFobpsWI42AXw/GnLjPJ/7n2qGOmVkwkSTBtGl3K1yhcOJttUr8axgQ2KXgiope7/7c41ljFoxsXtWnVUmbJiV+FE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2017 10:53:32.4507 (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: SN2PR03MB2366 Subject: [dpdk-dev] [PATCH v3 13/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 3de5238..b2413c2 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;