From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0067.outbound.protection.outlook.com [104.47.33.67]) by dpdk.org (Postfix) with ESMTP id 7E4395AA9 for ; Fri, 26 Aug 2016 15:58:08 +0200 (CEST) Received: from DM5PR03CA0006.namprd03.prod.outlook.com (10.175.104.16) by BY2PR0301MB0709.namprd03.prod.outlook.com (10.160.63.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Fri, 26 Aug 2016 13:58:05 +0000 Received: from BL2FFO11FD059.protection.gbl (2a01:111:f400:7c09::112) by DM5PR03CA0006.outlook.office365.com (2603:10b6:3:118::16) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9 via Frontend Transport; Fri, 26 Aug 2016 13:58:05 +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;nxp.com; dkim=none (message not signed) header.d=none; 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 BL2FFO11FD059.mail.protection.outlook.com (10.173.161.155) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Fri, 26 Aug 2016 13:58:05 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u7QDvHpq023630; Fri, 26 Aug 2016 06:58:02 -0700 From: Shreyansh Jain To: CC: , , , , Shreyansh Jain Date: Fri, 26 Aug 2016 19:26:53 +0530 Message-ID: <1472219823-29486-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131166934856279324; (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)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(106466001)(2351001)(586003)(229853001)(36756003)(110136002)(626004)(97736004)(189998001)(5660300001)(4326007)(47776003)(7846002)(87936001)(81156014)(81166006)(2950100001)(8936002)(86362001)(50226002)(104016004)(305945005)(8676002)(8666005)(356003)(575784001)(19580405001)(77096005)(68736007)(92566002)(11100500001)(50466002)(33646002)(85426001)(5003940100001)(2906002)(5890100001)(19580395003)(76176999)(48376002)(50986999)(105606002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0709; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD059; 1:IFIlvigPTZ4HhMVtRmQS0ao94ZKXSd9UvcKF9ZcNhvqgQZE9WRPlpUdhRk+XkkGF1r3xi5L3wlufSMYD3UnVFNCRD3oeVlscZVH9H4gLtpd9nrw2rljB7YA718amQ2XTk3OpHJTqFG+oBHBMvCoSAtll3ovRjTASiZyPp7sbuxGhYK7KvGIwt8+Upg03ZYWJUDN6runVnMYjEAkgqy9j425L1jSKZCClmwTrx1pMT5jV8Qqn/6QwYb4zIkgjZbvinzNzuQy0Pni/mu8ZAC7sW33h1u0a0tEKiQNwVTntyJT7VEWzWzWvfaiDylPCutzzE1mb6vy44n0D32RTxYAjSuPSqvbMSDe+jNBeFbpXVxqaYYn37e0JIEBgU4ARV1+NAsnfebHVCwG9WilCPYwT3SLCRUo15O6aiEyOs1ePDc06Mgt9yXqGbNvpjrAJOb468OfXwbcI/2gQS1+zNl4PNyYqePF3KGHccoeQzyf+L4zA/EHPYSoYh/A8K1t87IQEwMXolRh3QqDlX+SxbNlsIeI3KQvEiHfsuNuxxpS37MXXtR6M1EbJ1/RILoOAJ01/PDoGmCh0acSB1lN4+UWcxwsSUq3NXF8RxNWyWJSy9ThZ9L3OcGrvdAbH0CIYoMzSnSW91rPyEWZWsGbt6Kzs+Jp/G7rADcaFTxTaftWBVfeJnFNczKwB6eFm6KU5/Rm8bKDt/eq7T+UPnwgxP5MCUV9TDIEa/hu17LUWx//B1R0= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d91c62a4-f6e7-444a-38b3-08d3cdb900c4 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0709; 2:e0g2bkvxtzCCGiPvT+0ge4IkgFMFE3KJhqbggFEAXr2xyXfE3k+JWUtvH2dXc2lH9nJ0WiHT0gh25aGekquH6HxUcIT/Zv7JGJqYlVzKcWQeGeVBqYFMYmsDUfQYoPtbBvAjwCBJi0Ue5g4JTixzzHvXbOZAZVcgsWQLPbpWxHMLbR6AP67ls0ybUsugRk10; 3:AmO8mIVr+prlOh1z4f43dTM4jyigI8nm2rT6fyQL2sC4Af8MLCW0wK8V8da4yRtCTz5R3pA5gk79EWB5FfKo25cpUvpP8iNYNyo7OhHz0QyQaBGguNVVYUJ9flam3pTTRy+Gm5CxH0a4AS3PEwP1Ki80eTKMU7EkvHEwFf/u6S4WM53gLCSN8a/Lj4MnTuCcBmV21ZZe7J5P1n2jMypKY25nonz6G4UrmA1bbmfQZQw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0709; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0709; 25:mlURI35UexS/JFkc2k31F9aaVZZhK6Y/BeW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nd9ZEdbaBht6xi/Jv12mHxAL8nB5+ppHivpJicEW9/4Hfy/MBscYODjR1felFkoTxcqmOTPU1u/4xTugN6ReeW4Syo4yfyV7AdYN6hnfBraF+EPk+q7D3l9cPRxTIhvZPBT7uL4KtSM9VQvMLn/nFBkCHz5qLAKZSIvQ6mCfynvZTilSGBZNYO9Zai7G7Cyi3Dl0+or17V/L1ZFrNQDmTP9YtsLTcbOal0OZdZbOVqA0YIL30S2M9ShVyukVpm0J2b283Oa/k81JWJoy3BZ7FTzhpfSlA+HIHGwnyLSNxTwLjAflpbMljv5h0fhJZmTm/J53Y4jLu20i9yuJTnSgA35pbRQ/H03JbxLlffRVYFDZwD4kW0eg2J6hWlJlYulSQiYKLslZrBolET4rN4LvvULFhtfi++EZIgn93I5fv8oHnx+DPR7OAnHd0MBpnIufg8x82FeZ3UkMdZPATtX0ajY1Q5lXr5zxk57SZyEkBpcKQZLHWObdXIAG69g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13024025)(13015025)(13018025)(13023025)(13017025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BY2PR0301MB0709; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0709; X-Forefront-PRVS: 00462943DE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0709; 23:vKXvaJ+n1K1LiFlD3o24ZA7ynt8LKMGXRidM+rA?= =?us-ascii?Q?duzYPzL+zwEETLswDdgZq1srFwovdmW1qxUWSJEDNCejmjH3RLKiUAxYI/cR?= =?us-ascii?Q?QF5LXRJN4d2L8XJpQfrmQZMVT8RRG71RSggrMWGxsjpW9cmFTjFh8ZSTCiGa?= =?us-ascii?Q?ruave9A60DFqTDQCaMdHfIdnz8oNFtajz17UeSCZcdW33BMX6rJi15ZXfqZu?= =?us-ascii?Q?XBr82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adata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2016 13:58:05.3159 (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: BY2PR0301MB0709 Subject: [dpdk-dev] [PATCH v8 15/25] eal: extract vdev infra X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Aug 2016 13:58:10 -0000 Move all PMD_VDEV-specific code into a separate module and header file to not polute the generic code anymore. There is now a list of virtual devices available. The rte_vdev_driver integrates the original rte_driver inside (C inheritance). The rte_driver will be however change in the future to serve as a common base for all other types of drivers. The existing PMDs (PMD_VDEV) are to be modified later (there is no change for them at the moment). Unlike DRIVER_REGISTER_PCI, DRIVER_EXPORT_NAME is not being called on vdev registration. Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 54 +-------------- lib/librte_eal/common/eal_common_vdev.c | 110 +++++++++++++++++++++++++++++++ lib/librte_eal/common/include/rte_vdev.h | 84 +++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + 6 files changed, 198 insertions(+), 54 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_vdev.c create mode 100644 lib/librte_eal/common/include/rte_vdev.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 7a0fea5..5a3fc1d 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -69,6 +69,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index bb9810d..dfd64aa 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -38,7 +38,7 @@ INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h INC += rte_eal_memconfig.h rte_malloc_heap.h -INC += rte_hexdump.h rte_devargs.h rte_dev.h +INC += rte_hexdump.h rte_devargs.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 88f9d3f..555e0d9 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -64,32 +64,6 @@ rte_eal_driver_unregister(struct rte_driver *driver) } int -rte_eal_vdev_init(const char *name, const char *args) -{ - struct rte_driver *driver; - - if (name == NULL) - return -EINVAL; - - TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_VDEV) - continue; - - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "eth_pcap", but "name" will be "eth_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->name, name, strlen(driver->name))) - return driver->init(name, args); - } - - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; -} - -int rte_eal_dev_init(void) { struct rte_devargs *devargs; @@ -98,7 +72,7 @@ rte_eal_dev_init(void) /* * Note that the dev_driver_list is populated here * from calls made to rte_eal_driver_register from constructor functions - * embedded into PMD modules via the PMD_REGISTER_DRIVER macro + * embedded into PMD modules via the DRIVER_REGISTER_VDEV macro */ /* call the init function for each virtual device */ @@ -125,32 +99,6 @@ rte_eal_dev_init(void) return 0; } -int -rte_eal_vdev_uninit(const char *name) -{ - struct rte_driver *driver; - - if (name == NULL) - return -EINVAL; - - TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_VDEV) - continue; - - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "eth_pcap", but "name" will be "eth_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->name, name, strlen(driver->name))) - return driver->uninit(name); - } - - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; -} - int rte_eal_dev_attach(const char *name, const char *devargs) { struct rte_pci_addr addr; diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c new file mode 100644 index 0000000..d225e86 --- /dev/null +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -0,0 +1,110 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of RehiveTech nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +struct vdev_driver_list vdev_driver_list = + TAILQ_HEAD_INITIALIZER(vdev_driver_list); + +/* register a driver */ +void +rte_eal_vdrv_register(struct rte_vdev_driver *driver) +{ + TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next); +} + +/* unregister a driver */ +void +rte_eal_vdrv_unregister(struct rte_vdev_driver *driver) +{ + TAILQ_REMOVE(&vdev_driver_list, driver, next); +} + +int +rte_eal_vdev_init(const char *name, const char *args) +{ + struct rte_vdev_driver *driver; + + if (name == NULL) + return -EINVAL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (driver->driver.type != PMD_VDEV) + continue; + + /* + * search a driver prefix in virtual device name. + * For example, if the driver is pcap PMD, driver->name + * will be "eth_pcap", but "name" will be "eth_pcapN". + * So use strncmp to compare. + */ + if (!strncmp(driver->driver.name, name, strlen(driver->driver.name))) + return driver->driver.init(name, args); + } + + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + return -EINVAL; +} + +int +rte_eal_vdev_uninit(const char *name) +{ + struct rte_vdev_driver *driver; + + if (name == NULL) + return -EINVAL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (driver->driver.type != PMD_VDEV) + continue; + + /* + * search a driver prefix in virtual device name. + * For example, if the driver is pcap PMD, driver->name + * will be "eth_pcap", but "name" will be "eth_pcapN". + * So use strncmp to compare. + */ + if (!strncmp(driver->driver.name, name, strlen(driver->driver.name))) + return driver->driver.uninit(name); + } + + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + return -EINVAL; +} diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h new file mode 100644 index 0000000..9a2e2d5 --- /dev/null +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -0,0 +1,84 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of RehiveTech nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef RTE_VDEV_H +#define RTE_VDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** Double linked list of virtual device drivers. */ +TAILQ_HEAD(vdev_driver_list, rte_vdev_driver); + +/** + * A virtual device driver abstraction. + */ +struct rte_vdev_driver { + TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */ + struct rte_driver driver; /**< Inherited general driver. */ +}; + +/** + * Register a virtual device driver. + * + * @param driver + * A pointer to a rte_vdev_driver structure describing the driver + * to be registered. + */ +void rte_eal_vdrv_register(struct rte_vdev_driver *driver); + +/** + * Unregister a virtual device driver. + * + * @param driver + * A pointer to a rte_vdev_driver structure describing the driver + * to be unregistered. + */ +void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver); + +#define DRIVER_REGISTER_VDEV(nm, vdrv)\ +RTE_INIT(vdrvinitfn_ ##vdrv);\ +static void vdrvinitfn_ ##vdrv(void)\ +{\ + (vdrv).driver.name = RTE_STR(nm);\ + rte_eal_vdrv_register(&vdrv);\ +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 193957f..4e206f0 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c -- 2.7.4