From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0079.outbound.protection.outlook.com [104.47.1.79]) by dpdk.org (Postfix) with ESMTP id 62AB15F2C for ; Wed, 14 Mar 2018 09:02:19 +0100 (CET) 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=pYZLmkzMdWDZWqi7DLXYYVP7XnCoRpiqI6F3LstyHXE=; b=QF3gEFuGt2/J0W2DFB4dqoyg03vo9pWguYMqTtzl7HhdOLTpZ2tMqiEA3q0iAUOi+HuOfHBVYacN9tUTB1B/fI2m4/VYGkgiJB12hN+nnrfP1/9XzkPsN5MIbBSw5qf2WNRpiB4trPiguVunUpg/1N7RsdfyZW0otbbKJRtojOs= 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 AM3PR04MB0758.eurprd04.prod.outlook.com (2a01:111:e400:883c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.18; Wed, 14 Mar 2018 08:02:15 +0000 From: Hemant Agrawal To: dev@dpdk.org, bruce.richardson@intel.com Cc: thomas@monjalon.net, anatoly.burakov@intel.comm, xiao.w.wang@intel.com, junjie.j.chen@intel.com Date: Wed, 14 Mar 2018 13:30:34 +0530 Message-Id: <1521014434-3399-1-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR01CA0111.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::27) To AM3PR04MB0758.eurprd04.prod.outlook.com (2a01:111:e400:883c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 039bf15c-9def-46c9-cd98-08d58981e772 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM3PR04MB0758; X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB0758; 3:FXYroTrCxnDUMpwX0vyxB7O4Mf7F2eXxhVI0hFM92XcLdUqLkD3gtJAPzNdGLIIpQXoyhUHriRCrthEDLgP7ANJHhyU71rxBWTe+KPWgPwBAmCweFvfi1vCWz4RIq/jMe4ziVIluZQchdZ5mHm+I4YDBeKkdGwkzXbumzzXBwsXSwnH/JYEOQQgoq2sPP7Sg8jIsYBAPIQgufSR78ZkpIfBUT/+Yd2/ydnPxPasK/ohj6tbDaQJOjTkaIJJ6ztqZ; 25:5J3AJ2SNA8BVP0+h3ha2JCMUg5agRoKI3W2/fEJNXbmaai2xhwaK37yAPY64nj5DvCCz6IV5h9uRoP9r1k5cVIUd0+QRblVNqO4KyO9GyJgCQP4GDpXnb+3ZdvfcYokYx4WMSsT1mut+8WDedJMCvHptqN2lZNeQA0gvl3Jv4wgkHw0CWpHGlYJDHngUTQXg2hRP1teFtbhi2poFjhCdR7P25ah8Wx2qarlvJ/WYQfdqSvm0sCoQvy1aSnOGEhB6Q06mdreXvzA+bGnQfaLKciNSJ+5gEGO3BuwGqIa6H29UljpT72BBxrt1y6NJCtMtoErrhXXPKDV+31P/sBfpyg==; 31:Q43JAyo1hwSeuY2z4oBd6RMQKZ+orrrAgC8ULiHPWV5wOTDpL+B1kU6dvAfmWl/DtQV/lJ0iPphQvSYZBKefIuYm37GvKP3Gqf1kfQrw5146MxhvP5ZSScydV9k6ZqjrYeBVKJcrucvJkAU5VwTGSJKJ6RONiwwoq2FQiXN4beIQlhWBZHXQ4nEKDeqEi5oQOdYQtBXJQuzbyZ1GIcN21tqS8ADLBe3FscBs9oSLPJo= X-MS-TrafficTypeDiagnostic: AM3PR04MB0758: X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB0758; 20:q1LjF3vgtj+PnqunNk45+s78VYR9wsI1R9heLxiVHfmqo5PUWDjA5wI6wIiA4DZ0PBt+caQoJKZDPmsjOwl/dEpdM2whDU3DK9tLI4mkJMfJm4MSW1SQOyqf9kkEueK+mJYQX8uHlBsKOKG/ntWklXXqqkqWmB4eTfAIDRdX0Dz8oGajHhWSoOAPtVomhMeYdVPiBz/P1wjeEbBgnONhWSCkvzPk4SbuygELwg5IT1KMeviuUahfxmYsyUyiWyFiipjEUeFRzgEcxLC+s33custdvL5aY8VZNxW2BKec0PQJxi/qyRmkGAuXFNob0Xd/lcFg2vrOu8KcMp+1xCJL7o0Mje8QSvHck/QfPNjM4KlDNQ7saqMYuuzUolsgSzs6JbfW/+iFuZ8bv0Aq5zEXx0GD7Bj/b1Hi30uDQSQmKSNPbr/DP9uNXkB4y6z7ZL+/3MgQJgP8ex4QNF/tCO1pLlWYH8D6TOhk0QIoz+U1ht3Ugks25oUKuTruxk6VC+Gp; 4:+wmasYfjwb3GSDpvO1RYFhTlXA5s+KgMRzDKCX1I4T1eVwdjipSoDri2vvHwKTmrP9Oc48+ZxvMiriKE9NH+E/f3T0OXbhc9vcpWvQwrdNBweZYrvMT1QyWOPM4HYF8451gk0+FyPFpAdsZQ97L2jw2PlDcyT/L8ZuwlAkoiggcGkioDSMakG44szqIA1puhVKCmXpGTBqPxVqnX0zNr6U5KAXX5TEGVs3LA8GBYnkb+jSqbsJT+kDPO4FkYrEG1Gn8aMFtRalpgS55ZhyeYMtCVfw7nT0fG6HqWZUf7nO/U5HF51fMQKkQkOEa8Uuwb8o7/5+GeP+IkYU3/N5NFaPmEBlgF2Jtw612dgI+sfRE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501244)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:AM3PR04MB0758; BCL:0; PCL:0; RULEID:; SRVR:AM3PR04MB0758; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(366004)(396003)(39380400002)(376002)(199004)(189003)(6486002)(5660300001)(4326008)(5009440100003)(50226002)(8936002)(81166006)(305945005)(2906002)(47776003)(316002)(66066001)(25786009)(3846002)(6306002)(51416003)(81156014)(48376002)(7736002)(50466002)(52116002)(6512007)(6116002)(59450400001)(68736007)(8676002)(16586007)(36756003)(966005)(1857600001)(106356001)(105586002)(6666003)(97736004)(6506007)(86362001)(386003)(478600001)(16526019)(26005)(53936002)(55236004)(186003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR04MB0758; H:bf-netperf1.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR04MB0758; 23:wmFZLYOCHVQvi2Q6KsdBncHDQPknZVSX0CrtkCEFo?= =?us-ascii?Q?srFLxCos92AmoNpk+qk0FF26mahcUwejYqcAt8+CmH1lXxmwLhjsEP3iEIB1?= =?us-ascii?Q?2L9GFjQnFIf4apRqBYcNFfCmFb4aN64CvdDyFgW6i9vQjDFHGEAJkL9Sure0?= =?us-ascii?Q?ZwLQ+753JYU4zfpC8pmQZpydqBocuXjnwhvpjdLLI+DaR+6sqtpczqs1Xqf+?= =?us-ascii?Q?oT4jWqtK6tjPInB0wNF8bGyG20eXP0GwhIiGR1fiQRgH66CQYxn4f7+WOB5u?= =?us-ascii?Q?XjibUQgNuSPEwgfpKeEPoSd5UT/U7nWjveBCVN3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fOSi1OGN624hKknfrr4LkLk+muPn9NJhTo3qwn77WR0cN03zBRI9xlDJxD6sHhjKqQEB9VPT2w9axga8VyVoqpaBiy86KeYueUCNKyLDButEN2Rgh2viiXEtRazeO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 08:02:15.3077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 039bf15c-9def-46c9-cd98-08d58981e772 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR04MB0758 Subject: [dpdk-dev] [PATCH] 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: , X-List-Received-Date: Wed, 14 Mar 2018 08:02:19 -0000 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 --- This patch has some minor conflicts with "eal/vfio: add support for multiple container" https://dpdk.org/dev/patchwork/patch/35862/ however they can be resolved easily. drivers/bus/fslmc/Makefile | 1 - drivers/bus/fslmc/fslmc_vfio.c | 6 ++-- 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 | 47 ++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 18 +++++----- lib/librte_eal/linuxapp/eal/eal_vfio.h | 21 ------------ lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 4 +-- lib/librte_eal/rte_eal_version.map | 3 ++ 10 files changed, 84 insertions(+), 39 deletions(-) diff --git a/drivers/bus/fslmc/Makefile b/drivers/bus/fslmc/Makefile index 952b4c0..04814db 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -21,7 +21,6 @@ endif 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 e840ad6..4e1187e 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -94,7 +94,7 @@ 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_no(SYSFS_FSL_MC_DEVICES, g_container, groupid); if (ret <= 0) { FSLMC_VFIO_LOG(ERR, "Unable to find %s IOMMU group", g_container); @@ -128,7 +128,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) { FSLMC_VFIO_LOG(ERR, "Failed to open VFIO container"); return -errno; @@ -627,7 +627,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 4eafcb5..29cac28 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -781,3 +781,23 @@ int rte_vfio_clear_group(__rte_unused int vfio_group_fd) { return 0; } + +int __rte_experimental +rte_vfio_get_group_no(__rte_unused const char *sysfs_base, + __rte_unused const char *dev_addr, + __rte_unused int *iommu_group_no) +{ + 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_no) +{ + return -1; +} diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index e981a62..a9665c6 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -28,6 +28,12 @@ #define VFIO_NOIOMMU_MODE \ "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode" +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) +#define RTE_VFIO_NOIOMMU 8 +#else +#define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU +#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. @@ -123,6 +129,47 @@ int rte_vfio_noiommu_is_enabled(void); int rte_vfio_clear_group(int vfio_group_fd); +/** + * Parse IOMMU group number for a device + * + * This function is only relevant to linux and will return + * an error on BSD. + * + * @return + * 1 on success + * 0 for non-existent group + * <0 for errors + */ +int __rte_experimental +rte_vfio_get_group_no(const char *sysfs_base, + const char *dev_addr, int *iommu_group_no); + +/** + * 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. + * + * @return + * > 0 group fd + * < 0 for errors + */ +int __rte_experimental +rte_vfio_get_group_fd(int iommu_group_no); + #endif /* VFIO_PRESENT */ #endif /* _RTE_VFIO_H_ */ diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index e44ae4d..3dc2c18 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -36,7 +36,7 @@ static const struct vfio_iommu_type iommu_types[] = { }; int -vfio_get_group_fd(int iommu_group_no) +rte_vfio_get_group_fd(int iommu_group_no) { int i; int vfio_group_fd; @@ -266,7 +266,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr, int ret; /* get group number */ - ret = vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); + ret = rte_vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); if (ret == 0) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n", dev_addr); @@ -278,7 +278,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_no); if (vfio_group_fd < 0) return -1; @@ -398,7 +398,7 @@ rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, int ret; /* get group number */ - ret = vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); + ret = rte_vfio_get_group_no(sysfs_base, dev_addr, &iommu_group_no); if (ret <= 0) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver\n", dev_addr); @@ -407,9 +407,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_no); 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); return -1; } @@ -480,7 +480,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) { @@ -558,7 +558,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; @@ -622,7 +622,7 @@ vfio_get_container_fd(void) } int -vfio_get_group_no(const char *sysfs_base, +rte_vfio_get_group_no(const char *sysfs_base, const char *dev_addr, int *iommu_group_no) { char linkname[PATH_MAX]; diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h index 8059577..c72b76c 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.h +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h @@ -79,12 +79,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 /* @@ -133,21 +127,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 d123602..7522b2b 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -254,5 +254,8 @@ EXPERIMENTAL { rte_service_set_runstate_mapped_check; rte_service_set_stats_enable; rte_service_start_with_defaults; + rte_vfio_get_group_no; + rte_vfio_get_container_fd; + rte_vfio_get_group_fd; } DPDK_18.02; -- 2.7.4