From patchwork Thu Apr 12 06:23:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 133187 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1364442ljb; Wed, 11 Apr 2018 23:25:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FJxFlWDsAsa7DqDuNZUhd45wMMV6kB9jJiJGU83KCrTbEGxH957vMj0rtlD0sVEha7oKm X-Received: by 10.28.74.88 with SMTP id x85mr4875048wma.85.1523514347574; Wed, 11 Apr 2018 23:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523514347; cv=none; d=google.com; s=arc-20160816; b=jgBYjx98j9GCqxivkZ6BgIdaF1LZqshEB/LV2X8lMgAOjRvejrV5l+RIfnFlYt6Khm uGcjlsXYUde15aFpbGXV/gVTLmugujHPpgFgIB71tjO73xtrJkfjMH6AV+iFUdOqkFOI UWQkeBkfzulq2P9Nh/tUmCVpUJ20atzzU/ZSwSufaQYB7SNch44oebTBOWgwDpCc3N0B e9JTJA1cf6Ky42Ve0/qTDzieZmEI/QE7AfQY7WdQtnw3aAh9tYKf1KVEvBg+Bgn8Smkq Hrd6kX7aZonNI4FawbGcisQ+JZHvuJIxXSM06QGyqS9nymdSizthgr3SU5JAsddz1jHC h9tw== 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:dkim-signature:arc-authentication-results; bh=GIPz86zQ/YIG8tT9PaNzKshkeuOxsqQLOzYS8T/sefo=; b=aZOfhAgYUOJDlkZ0KGdZAhoqqX8/sxVwJSYmVC6HGGws8aLCAKZC28Z5eEC/4JV5G8 gFL8ilmyXP7Bt+NPZ2GYBVKQxvTga5RG7p2+6k0PXEOi4PoU5t+9ND5snq7K4EI9PJs+ KSjLDieyqfeXAVjSFHNUcaZAmvL1mBpx4UnIrZAmcfa7JeIXaYFGpsGRAG/v1OvKCJLS QA3ltJe4sNicMj82AUOt2oIbWI2rKqxWIAWE/Wg9AaD4iLKrPRa4X+10Ox5sM7d/3i3a HAqzdcbE2Ba8hLgS10VkRgvszLHvoBNjDC0ypQ5tzXzvqFoPdMPUa0Z1UX8/cyL7EC0V lOnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b=ckgwSxHa; 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 x1si2057239wre.466.2018.04.11.23.25.47; Wed, 11 Apr 2018 23:25:47 -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; dkim=fail header.i=@nxp.com header.s=selector1 header.b=ckgwSxHa; 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 54EC01BACA; Thu, 12 Apr 2018 08:25:44 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50067.outbound.protection.outlook.com [40.107.5.67]) by dpdk.org (Postfix) with ESMTP id 484271BA98 for ; Thu, 12 Apr 2018 08:25:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GIPz86zQ/YIG8tT9PaNzKshkeuOxsqQLOzYS8T/sefo=; b=ckgwSxHaA4nfM1cdewAApcNQWiuaKwqK4qpKQYxVEBNiN5wDEVWoSOEWKMjngi0ZMDXJ0LhLhmAOVb6reBjUPeW8nJOpy6ZwLtAjkNbrTlgKHDO/wlU66qCg0HqRzhRdw84+G2MEjJXCoZB/STvMru832AWxYCFXMALaE4DU6iw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; Received: from bf-netperf1.ap.freescale.net (14.142.187.166) by DB3PR04MB0764.eurprd04.prod.outlook.com (2a01:111:e400:9440::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Thu, 12 Apr 2018 06:25:36 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: anatoly.burakov@intel.com, thomas@monjalon.net Date: Thu, 12 Apr 2018 11:53:37 +0530 Message-Id: <1523514217-12580-2-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523514217-12580-1-git-send-email-hemant.agrawal@nxp.com> References: <1522828120-16100-1-git-send-email-hemant.agrawal@nxp.com> <1523514217-12580-1-git-send-email-hemant.agrawal@nxp.com> MIME-Version: 1.0 X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BMXPR01CA0045.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::31) To DB3PR04MB0764.eurprd04.prod.outlook.com (2a01:111:e400:9440::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB3PR04MB0764; X-Microsoft-Exchange-Diagnostics: 1; DB3PR04MB0764; 3:5mol57qcndgGbY7gTQ+MpXHq05JG9H8l4I372Cp/LNx7cMZe3gy+F1iv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5AqCzIfCZoEBqJLOjYME09M21x+bphXvaaOCxKejEPDna8Sqezz3tuTKPJphmMhIFDJ9N01Nh9SEE7j+Ha/ZBV/2bDHSBuq5ewhK58aKSqN1qCayvGrwP+KUI+6/CSbGzqNz+1j1TX/6OLC35+/aMB9U54FdwcZuS/V+O8F1dFoyflbSCXOk4VDcJQm70g0LlvqtJ9LNE4h01oAgKCeMCerNGRxnCOKc4gfrm9O4BDzAZopXLuO6i3/mU1qYElHKDXfWMer4PAsFusfYChxFenp6hatUyL84LwaV; 4:M9qHs84ABSzl/bb5g2j9cHKNn7+4Vkg2C9C3bsZm26CHYtTBGESrmHGObMxG8ylOtKQWfaF99L3yNWSmtW1BdG44NIZQT7sritNBVdko6hYLJIh5daN48oW1FoS3IORh7utxv32gtAiE6Ig6sd4NxuDwvvfm/RvFTwH8JGp6hEnXiHV8wEW8fl0s471h8D5rRp0njvZYC4oNYndhMFNv8ENM3pMXBHf+YXk9l5zCPujmd5LKOxaDgRDf5ZtclYWdfXpFEqg8DlJokZtuCn1UN4u7pdcihJunc/9JxKoXqYPSDq9lA4f8hSHOq76tM2BxkCwEXUDw9HATF7qTnIB57mQ9J9lQFnrpEL3tBm4fb1vz2BNcMoESnsESV+jSiAKj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:DB3PR04MB0764; BCL:0; PCL:0; RULEID:; SRVR:DB3PR04MB0764; X-Forefront-PRVS: 06400060E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(39380400002)(189003)(199004)(106356001)(5009440100003)(2361001)(2351001)(16586007)(316002)(8676002)(5660300001)(81156014)(81166006)(50226002)(305945005)(8936002)(105586002)(7736002)(53936002)(478600001)(36756003)(6512007)(4326008)(2906002)(25786009)(48376002)(6916009)(3846002)(68736007)(6486002)(6116002)(26005)(50466002)(186003)(97736004)(51416003)(6506007)(55236004)(52116002)(386003)(11346002)(47776003)(446003)(16526019)(956004)(59450400001)(76176011)(66066001)(2616005)(486006)(476003)(86362001)(575784001)(44832011)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR04MB0764; H:bf-netperf1.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB3PR04MB0764; 23:x+aAXYi22c4eXWoROJguqrZfshJm5zW7LlCfhC2GL?= BqBsPwDu2XdTTkqXI0E0GFI6d2JSdqJY0ljmRs4jq0ETVexMoV7txrA+xASEAiivBkrAr3SihtdZnCJ61j5ToSpeXU32PG49oIYIlvVRlGAhfzCgrOf1VP+H5/xRVOUO5eXg+HpV3e94jLI4vV3rmHb0kXRF2jZZFO6NwyjZ0KV0J8EsfxlG3sCQUOSpC+EYWcLPie9hE3nVtS2cIYy3v7QLqPOCG1q0jflhJdRrAlDo2KGArf5XxZf0nn37Mul/18/lnlcp8yUYMK9BssO+jJiIq1/o+KupufOM0B1e9Sk3tmIWlH8bOFq655e013GHYZMJYFEay3Loxki8hKxvXh5dYgbr34RZo3BXpZFuNLLBYIRWwvjrdrRmPe4wKybMYIOnkCEmm2VePYZhjGrVpsUqBeHyKf6rJajz89vWWJTbHnqheU9deoVcB6apPGWq/DaCdW9gZ5lWTpoY41AG/LF8zHizXfAwu8F0Si9cVgXPUPvF9NT4WYJ+MPMeJmzpCfUB/fahscFREtYdfK7PnGdjmebfMJ2/O8PfGTSn9PYstRqvgqrZ34rrGOABOWwhZF7WzBNi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q+GVgKNUINDbjVMIX5v2Uw6ilyhCDUPX/1vvBJ9ibm3VHk7aCVPQJqPW4XGhZ1zltByUyCJKEyZbdVuR74x8RlcbXY/aRajy6gqg8q6qY5KaK9l7St9h9zMyo9+d283BR9ggDIRM3hICJK/vjEqGfcKb5M23sJRvLxV7NV0bN9gg/XD3Qh3N2FlYepvV4Ku9RCIBExgKgL/pvaUlbkpK6/dyqqG/Ko1RNSD45DBo0zEO8BIpjg43UA+MQKu6OSiBpqDh+JYw0Tnpn9H319XzhfBcsufeFdIOcrM0AL7fG8TZLg2rrqiF6F9hGAlFvmS/Kh8hR0rUE8SNYfk0z3KcPKgu5xlK/w9/k7D+YB5+glm9zsIK2E6MGrH8zwQ==; 5:KmAJF0MiVLdBl1sWTU/OGOtF57ioEGlIgiE3lnSkuwX6ONU67oqpxBSLZl5VtUIy1rjZOuRtcaq6bLms75mN5vo1fkzrce1rt88NDxHwaWkq4/AOuxOsXcIg0QQwbA4Ql+/r2bzNlpaP4Oq6XpzpmvtRFi83nr3pirebb4sDBQc=; 24:i1c/nla2OiqfLj4E8l7CLdKSteEwG/X21e0ChiDl8dlXLNN3tSiFHP216jVBnzEyZHOJKQyADIMsYDfQUTcJcX0h6n0OFVwLEMaYiR37wo4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB3PR04MB0764; 7:AN+LS6aitAGWvPXucUGdJlggmmOn29JcRLhAGr06Rn8CDxe0Slj+C9mu3FL3HRJJPozSpg5/SWHtnJbl/YBv3gnJ43TglNPlM/j0EUufgKQ9J7z661TrN3DODpijJCszxIu1jJRlsAVxO/NphM/uZqrDZbN4b7vghGGNeXqaaU4XayTrTI6UotQlhg/WxbFiTUxPLFpAvZeNP/0qjMfreMoeicYA1AEq0FzEZY4ctSh4fxFvzRReAd/3Bc0qq4mC X-MS-Office365-Filtering-Correlation-Id: 42525939-613b-4b6f-e3f7-08d5a03e34c4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2018 06:25:36.7310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42525939-613b-4b6f-e3f7-08d5a03e34c4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR04MB0764 Subject: [dpdk-dev] [PATCH v6 2/2] eal/vfio: export internal vfio functions 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" This patch moves some of the internal vfio functions from eal_vfio.h to rte_vfio.h for common uses with "rte_" prefix. This patch also change the FSLMC bus usages from the internal VFIO functions to external ones with "rte_" prefix Signed-off-by: Hemant Agrawal Acked-by: Anatoly Burakov --- v6: rebase on latest master drivers/bus/fslmc/Makefile | 1 - drivers/bus/fslmc/fslmc_vfio.c | 7 +-- drivers/bus/fslmc/fslmc_vfio.h | 2 - drivers/bus/fslmc/meson.build | 1 - lib/librte_eal/bsdapp/eal/eal.c | 20 +++++++ lib/librte_eal/common/include/rte_vfio.h | 74 +++++++++++++++++++++++++- lib/librte_eal/linuxapp/eal/eal_vfio.c | 45 ++++++++-------- lib/librte_eal/linuxapp/eal/eal_vfio.h | 23 +------- lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 4 +- lib/librte_eal/rte_eal_version.map | 3 ++ 10 files changed, 126 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/drivers/bus/fslmc/Makefile b/drivers/bus/fslmc/Makefile index 93870ba..3aa34e2 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -16,7 +16,6 @@ CFLAGS += $(WERROR_FLAGS) 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 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 625fa7c..4036e82 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -91,7 +91,8 @@ fslmc_get_container_group(int *groupid) } /* get group number */ - ret = vfio_get_group_no(SYSFS_FSL_MC_DEVICES, g_container, groupid); + ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES, + g_container, groupid); if (ret <= 0) { DPAA2_BUS_ERR("Unable to find %s IOMMU group", g_container); return -1; @@ -124,7 +125,7 @@ vfio_connect_container(void) } /* Opens main vfio file descriptor which represents the "container" */ - fd = vfio_get_container_fd(); + fd = rte_vfio_get_container_fd(); if (fd < 0) { DPAA2_BUS_ERR("Failed to open VFIO container"); return -errno; @@ -726,7 +727,7 @@ fslmc_vfio_setup_group(void) } /* Get the actual group fd */ - ret = vfio_get_group_fd(groupid); + ret = rte_vfio_get_group_fd(groupid); if (ret < 0) return ret; vfio_group.fd = ret; diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h index e8fb344..9e2c4fe 100644 --- a/drivers/bus/fslmc/fslmc_vfio.h +++ b/drivers/bus/fslmc/fslmc_vfio.h @@ -10,8 +10,6 @@ #include -#include "eal_vfio.h" - #define DPAA2_MC_DPNI_DEVID 7 #define DPAA2_MC_DPSECI_DEVID 3 #define DPAA2_MC_DPCON_DEVID 5 diff --git a/drivers/bus/fslmc/meson.build b/drivers/bus/fslmc/meson.build index e94340e..78f9d92 100644 --- a/drivers/bus/fslmc/meson.build +++ b/drivers/bus/fslmc/meson.build @@ -22,6 +22,5 @@ sources = files('fslmc_bus.c', allow_experimental_apis = true -includes += include_directories('../../../lib/librte_eal/linuxapp/eal') includes += include_directories('mc', 'qbman/include', 'portal') cflags += ['-D_GNU_SOURCE'] diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 727adc5..bfbec0d 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -818,3 +818,23 @@ rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova, { return -1; } + +int __rte_experimental +rte_vfio_get_group_num(__rte_unused const char *sysfs_base, + __rte_unused const char *dev_addr, + __rte_unused int *iommu_group_num) +{ + return -1; +} + +int __rte_experimental +rte_vfio_get_container_fd(void) +{ + return -1; +} + +int __rte_experimental +rte_vfio_get_group_fd(__rte_unused int iommu_group_num) +{ + return -1; +} diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index f363cac..c4a2e60 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -37,6 +37,13 @@ extern "C" { #endif +/* NOIOMMU is defined from kernel version 4.5 onwards */ +#ifdef VFIO_NOIOMMU_IOMMU +#define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU +#else +#define RTE_VFIO_NOIOMMU 8 +#endif + /** * Setup vfio_cfg for the device identified by its address. * It discovers the configured I/O MMU groups or sets a new one for the device. @@ -128,7 +135,19 @@ int rte_vfio_is_enabled(const char *modname); */ int rte_vfio_noiommu_is_enabled(void); -/* remove group fd from internal VFIO group fd array */ +/** + * Remove group fd from internal VFIO group fd array/ + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param vfio_group_fd + * VFIO Grouup FD. + * + * @return + * 0 on success. + * <0 on failure. + */ int rte_vfio_clear_group(int vfio_group_fd); @@ -170,8 +189,61 @@ rte_vfio_dma_map(uint64_t vaddr, uint64_t iova, uint64_t len); * 0 if success. * -1 on error. */ + int __rte_experimental rte_vfio_dma_unmap(uint64_t vaddr, uint64_t iova, uint64_t len); +/** + * Parse IOMMU group number for a device + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param sysfs_base + * sysfs path prefix. + * + * @param dev_addr + * device location. + * + * @param iommu_group_num + * iommu group number + * + * @return + * >0 on success + * 0 for non-existent group or VFIO + * <0 for errors + */ +int __rte_experimental +rte_vfio_get_group_num(const char *sysfs_base, + const char *dev_addr, int *iommu_group_num); + +/** + * Open VFIO container fd or get an existing one + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @return + * > 0 container fd + * < 0 for errors + */ +int __rte_experimental +rte_vfio_get_container_fd(void); + +/** + * Open VFIO group fd or get an existing one + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @param iommu_group_num + * iommu group number + * + * @return + * > 0 group fd + * < 0 for errors + */ +int __rte_experimental +rte_vfio_get_group_fd(int iommu_group_num); #ifdef __cplusplus } diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index 589d7d4..984b1a1 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -284,7 +284,7 @@ compact_user_maps(void) } int -vfio_get_group_fd(int iommu_group_no) +rte_vfio_get_group_fd(int iommu_group_num) { int i; int vfio_group_fd; @@ -293,7 +293,7 @@ vfio_get_group_fd(int iommu_group_no) /* check if we already have the group descriptor open */ for (i = 0; i < VFIO_MAX_GROUPS; i++) - if (vfio_cfg.vfio_groups[i].group_no == iommu_group_no) + if (vfio_cfg.vfio_groups[i].group_num == iommu_group_num) return vfio_cfg.vfio_groups[i].fd; /* Lets see first if there is room for a new group */ @@ -304,7 +304,7 @@ vfio_get_group_fd(int iommu_group_no) /* Now lets get an index for the new group */ for (i = 0; i < VFIO_MAX_GROUPS; i++) - if (vfio_cfg.vfio_groups[i].group_no == -1) { + if (vfio_cfg.vfio_groups[i].group_num == -1) { cur_grp = &vfio_cfg.vfio_groups[i]; break; } @@ -318,7 +318,7 @@ vfio_get_group_fd(int iommu_group_no) if (internal_config.process_type == RTE_PROC_PRIMARY) { /* try regular group format */ snprintf(filename, sizeof(filename), - VFIO_GROUP_FMT, iommu_group_no); + VFIO_GROUP_FMT, iommu_group_num); vfio_group_fd = open(filename, O_RDWR); if (vfio_group_fd < 0) { /* if file not found, it's not an error */ @@ -330,7 +330,8 @@ vfio_get_group_fd(int iommu_group_no) /* special case: try no-IOMMU path as well */ snprintf(filename, sizeof(filename), - VFIO_NOIOMMU_GROUP_FMT, iommu_group_no); + VFIO_NOIOMMU_GROUP_FMT, + iommu_group_num); vfio_group_fd = open(filename, O_RDWR); if (vfio_group_fd < 0) { if (errno != ENOENT) { @@ -343,7 +344,7 @@ vfio_get_group_fd(int iommu_group_no) /* noiommu group found */ } - cur_grp->group_no = iommu_group_no; + cur_grp->group_num = iommu_group_num; cur_grp->fd = vfio_group_fd; vfio_cfg.vfio_active_groups++; return vfio_group_fd; @@ -365,7 +366,7 @@ vfio_get_group_fd(int iommu_group_no) close(socket_fd); return -1; } - if (vfio_mp_sync_send_request(socket_fd, iommu_group_no) < 0) { + if (vfio_mp_sync_send_request(socket_fd, iommu_group_num) < 0) { RTE_LOG(ERR, EAL, " cannot send group number!\n"); close(socket_fd); return -1; @@ -380,7 +381,7 @@ vfio_get_group_fd(int iommu_group_no) /* if we got the fd, store it and return it */ if (vfio_group_fd > 0) { close(socket_fd); - cur_grp->group_no = iommu_group_no; + cur_grp->group_num = iommu_group_num; cur_grp->fd = vfio_group_fd; vfio_cfg.vfio_active_groups++; return vfio_group_fd; @@ -487,7 +488,7 @@ rte_vfio_clear_group(int vfio_group_fd) i = get_vfio_group_idx(vfio_group_fd); if (i < 0) return -1; - vfio_cfg.vfio_groups[i].group_no = -1; + vfio_cfg.vfio_groups[i].group_num = -1; vfio_cfg.vfio_groups[i].fd = -1; vfio_cfg.vfio_groups[i].devices = 0; vfio_cfg.vfio_active_groups--; @@ -544,11 +545,11 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr, .argsz = sizeof(group_status) }; int vfio_group_fd; - int iommu_group_no; + int iommu_group_num; int i, ret; /* get group number */ - ret = vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); + ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num); if (ret == 0) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n", dev_addr); @@ -560,7 +561,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr, return -1; /* get the actual group fd */ - vfio_group_fd = vfio_get_group_fd(iommu_group_no); + vfio_group_fd = rte_vfio_get_group_fd(iommu_group_num); if (vfio_group_fd < 0) return -1; @@ -733,7 +734,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, .argsz = sizeof(group_status) }; int vfio_group_fd; - int iommu_group_no; + int iommu_group_num; int ret; /* we don't want any DMA mapping messages to come while we're detaching @@ -743,7 +744,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, rte_rwlock_read_lock(mem_lock); /* get group number */ - ret = vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); + ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num); if (ret <= 0) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver\n", dev_addr); @@ -753,9 +754,9 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, } /* get the actual group fd */ - vfio_group_fd = vfio_get_group_fd(iommu_group_no); + vfio_group_fd = rte_vfio_get_group_fd(iommu_group_num); if (vfio_group_fd <= 0) { - RTE_LOG(INFO, EAL, "vfio_get_group_fd failed for %s\n", + RTE_LOG(INFO, EAL, "rte_vfio_get_group_fd failed for %s\n", dev_addr); ret = -1; goto out; @@ -818,7 +819,7 @@ rte_vfio_enable(const char *modname) for (i = 0; i < VFIO_MAX_GROUPS; i++) { vfio_cfg.vfio_groups[i].fd = -1; - vfio_cfg.vfio_groups[i].group_no = -1; + vfio_cfg.vfio_groups[i].group_num = -1; vfio_cfg.vfio_groups[i].devices = 0; } @@ -841,7 +842,7 @@ rte_vfio_enable(const char *modname) return 0; } - vfio_cfg.vfio_container_fd = vfio_get_container_fd(); + vfio_cfg.vfio_container_fd = rte_vfio_get_container_fd(); /* check if we have VFIO driver enabled */ if (vfio_cfg.vfio_container_fd != -1) { @@ -919,7 +920,7 @@ vfio_has_supported_extensions(int vfio_container_fd) } int -vfio_get_container_fd(void) +rte_vfio_get_container_fd(void) { int ret, vfio_container_fd; @@ -983,8 +984,8 @@ vfio_get_container_fd(void) } int -vfio_get_group_no(const char *sysfs_base, - const char *dev_addr, int *iommu_group_no) +rte_vfio_get_group_num(const char *sysfs_base, + const char *dev_addr, int *iommu_group_num) { char linkname[PATH_MAX]; char filename[PATH_MAX]; @@ -1016,7 +1017,7 @@ vfio_get_group_no(const char *sysfs_base, errno = 0; group_tok = tok[ret - 1]; end = group_tok; - *iommu_group_no = strtol(group_tok, &end, 10); + *iommu_group_num = strtol(group_tok, &end, 10); if ((end != group_tok && *end != '\0') || errno != 0) { RTE_LOG(ERR, EAL, " %s error parsing IOMMU number!\n", dev_addr); return -1; diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index 549f442..c788bba 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -81,12 +81,6 @@ struct vfio_iommu_spapr_tce_info { #define RTE_VFIO_SPAPR VFIO_SPAPR_TCE_v2_IOMMU #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) -#define RTE_VFIO_NOIOMMU 8 -#else -#define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU -#endif - #define VFIO_MAX_GROUPS RTE_MAX_VFIO_GROUPS /* @@ -103,7 +97,7 @@ int vfio_mp_sync_connect_to_primary(void); * the group fd via an ioctl() call. */ struct vfio_group { - int group_no; + int group_num; int fd; int devices; }; @@ -145,21 +139,6 @@ vfio_set_iommu_type(int vfio_container_fd); int vfio_has_supported_extensions(int vfio_container_fd); -/* open container fd or get an existing one */ -int -vfio_get_container_fd(void); - -/* parse IOMMU group number for a device - * returns 1 on success, -1 for errors, 0 for non-existent group - */ -int -vfio_get_group_no(const char *sysfs_base, - const char *dev_addr, int *iommu_group_no); - -/* open group fd or get an existing one */ -int -vfio_get_group_fd(int iommu_group_no); - int vfio_mp_sync_setup(void); #define SOCKET_REQ_CONTAINER 0x100 diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c index 7cc3c15..e19b571 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c @@ -267,7 +267,7 @@ vfio_mp_sync_thread(void __rte_unused * arg) switch (ret) { case SOCKET_REQ_CONTAINER: - fd = vfio_get_container_fd(); + fd = rte_vfio_get_container_fd(); if (fd < 0) vfio_mp_sync_send_request(conn_sock, SOCKET_ERR); else @@ -283,7 +283,7 @@ vfio_mp_sync_thread(void __rte_unused * arg) continue; } - fd = vfio_get_group_fd(vfio_data); + fd = rte_vfio_get_group_fd(vfio_data); if (fd < 0) vfio_mp_sync_send_request(conn_sock, SOCKET_ERR); diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 2b5b1dc..603c744 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -286,5 +286,8 @@ EXPERIMENTAL { rte_socket_id_by_idx; rte_vfio_dma_map; rte_vfio_dma_unmap; + rte_vfio_get_container_fd; + rte_vfio_get_group_fd; + rte_vfio_get_group_num; } DPDK_18.02;