From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0065.outbound.protection.outlook.com [104.47.36.65]) by dpdk.org (Postfix) with ESMTP id 6AECD6CD6 for ; Sat, 15 Oct 2016 15:44:30 +0200 (CEST) Received: from BN6PR03CA0016.namprd03.prod.outlook.com (10.168.230.154) by BY1PR03MB1420.namprd03.prod.outlook.com (10.162.127.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12; Sat, 15 Oct 2016 13:44:28 +0000 Received: from BY2FFO11FD021.protection.gbl (2a01:111:f400:7c0c::124) by BN6PR03CA0016.outlook.office365.com (2603:10b6:404:23::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.659.11 via Frontend Transport; Sat, 15 Oct 2016 13:44:27 +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 BY2FFO11FD021.mail.protection.outlook.com (10.1.15.210) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Sat, 15 Oct 2016 13:44:26 +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 u9FDhhgJ021870; Sat, 15 Oct 2016 06:44:23 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Sat, 15 Oct 2016 19:14:54 +0530 Message-ID: <1476539108-13170-4-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> References: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131210126676478465; (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)(1110001)(1109001)(339900001)(189002)(199003)(81166006)(2351001)(33646002)(105606002)(5003940100001)(626004)(86362001)(110136003)(8666005)(356003)(104016004)(7846002)(305945005)(6666003)(6916009)(2950100002)(36756003)(5660300001)(189998001)(87936001)(85426001)(97736004)(575784001)(5890100001)(8936002)(50466002)(50226002)(92566002)(48376002)(8676002)(19580395003)(19580405001)(47776003)(106466001)(586003)(68736007)(77096005)(50986999)(76176999)(81156014)(4326007)(2906002)(229853001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR03MB1420; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD021; 1:kWptyUIIF0/RFKcQeM7PkTfq3uUcBhhJQBb61wrHDPmQ83zvmQcQY+hUl7Y0CZVcdZJJwLLqPTGAgDvqepzzN2xjtkM0igH4TC7An0DdRd4DKIUaVINlRCDtmnvAxeC4w87VMkIsqbzgqRuZsx0r+o9OgWcTkzsE7Um4G+1QaBoUGTfSaRNhty+a4I6mv4HfjyvjWsr/YJwQd1XNTDuxtS3WFuy6K88simBhZePVzT+mPGwKgkXFfcZRTha6z6i7QKKT29Ig0k7WMTAVW+ut2mpXigj2NaGrC5qV3n56SYLksGCXcr0Pk87EbXGDgSrDtiDqEBZ3cZzEp8I/gNnyQkJ1LomeKaa2J2cIvx0TE/Qa4d1esJ66NBbcDHhkFT9HmorXHzxWYjb0mFdwo4j1u20W0EowDPlXlrI5yPMPUEH9nv2y7VdkVTU+d6Urf+lqgO5ZT3KTmAH7Qnv4GIqUrMJrP9K6QIRVXbZJ8sWUEIq2fKvJVoh6W+UdoBFdwBZk1vtVumfGrWTb0v88tLgJiSE7174yJr8R6FcGcSOvCPsfIktcmJj9w75gUgDVCetSPsq2YUBABpmiplqhCnmLonRIPwTHsb8ZupYbq+qrpgHkBPzAx6uAJAHe3oiyCgKPyWp6bwtVKkCV6xKFUbb3Ds+BCPHYVOMgIkHbHtFwk28AQcb/ShPYQTXwdKe7YrQJlzjV/7tyj0vb25PeK5NVDCPFWqa0/4p9yIOgeLQPsAc= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5d5cd031-9b02-4178-e8a1-08d3f50161f0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 2:L5ROH7hNKf5HUPtRqe4dOOdk1yncgdlRVxsIlk9OITljE4zhx9UG/bCokoSNXwrRyZnd4NPCafDm4pCBI2GalHJda76+s8GQVO0P7PA3PnsC9hbL1u/OoDph7p96Q1WWfW4GkIGcIm+zVmsQAkpPPqr9tFwLSLMWq9TZHEmno57YQ2WtgotidYnFVmy9d2Uddb9l08VssuUZguB1GIkF1w==; 3:gqBbB094dHgF23bHP30UKrAIty98XmQ0CFr0peZtZT43XCstm9k/ZaLk/WFXXWWHrKWpEsHPGv+FapF90XU1oJjdwSpHemyRWZHAIIPFOwh1IPKJGArE0Z0WID29Pb4Hj7x5Rstap5IKhodmBZJgYRtiuLs+n7/+yqL6zqDwfJ0HJj/V1ZBiGrHU/l9fWyBGap3s05noZZRCH0fYM3TQA8ROLdpckrfx6IFO2WSM/mnth3SrQBpMAC5g1FvRdlAd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1420; X-Microsoft-Exchange-Diagnostics: 1;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3bpZgvACnayq40vkOkVQwSbTl9Hp9PI1H4tkeeb+mOTn0/bP+L0bJWREDoYycpX3gYRUGAP0YwA==; 4:0PdS6EFabgF/5O40I1eT4mu0XuA+1+MfQhgjYikgtdODke7JH2aWiAcK/02W+tp4Ig4uOHOw02QZrOPx3Yel9vE8zQjjbmlAGisXI5FU6ggyFeyGYbQQK71HIjenzZkwyqEV+s9cBmJ3FE4UmUQycHg3ysg2ygzSbAvc4tDTWkBmQK85YuHOY6OsdFaZfQ1qmsEn4dJ2VWP/9G04xkAjW7/zvhKFEi3pzcSM/AhdV814Jy67+k5TaS9YG+9Y8+S13YQYpKWXtlTakxOWpHgwUwRIyG71y2Zgb4QEivT77RF0rWRIgmtLM4Smrs7AYHrJKEVQP2P8Fp3NumKgnHz/Ot091EZD9B3o+lskI61Bchzo1s3zR9X2Izq28mrLkCqHV7j9Gh7RbzSRz69e9kPF/YHh3SPUOH1eB0E1aQkxre91GuFwCJo7LCvwRMM3PAo/bKMHGI5EfmC9QsR8u3zM/BiGVaoGHVZTHT9nh62OjNP14MWHHmmj7IlIOeCJOAypEmNpPYNTzRIQWZAJf5LzsCn6N+uD8RkgpEbTEsQvAqIgiFqJ8UZgPfdGptuu9O0E X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(13018025)(13017025)(13023025)(13015025)(13024025)(3002001)(10201501046)(6055026); SRVR:BY1PR03MB1420; BCL:0; PCL:0; RULEID:(400006); SRVR:BY1PR03MB1420; X-Forefront-PRVS: 00963989E5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1420; 23:3qYjoot9JYzeOH/QQ+El10u9CWfYupSaoi8QeltNz?= =?us-ascii?Q?zYWqfVYyN6mvPDJrf72WuyKjCOfdqFHhQyAtPPpf5cR03eiqwVmtnxtogX3q?= =?us-ascii?Q?/Dm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xtgq3?= =?us-ascii?Q?XnpZ0sdZXxlbNCKarz7ocPvbHau0W7yMLWgTqNHeei9plhoNjpr7Hi/6rb+D?= =?us-ascii?Q?72jnPm4DEIeZZWxQkehK71gt3EDmt4Y6UDZFhIFUMBARVHzE0wATW+qHgr1c?= =?us-ascii?Q?h56zap/sjrg5U4cKs7L422cnO5YqICWkdmk53zPQlELjtlvFBC6uEXirwk48?= =?us-ascii?Q?7CYaAro9sXCwGCWvvX5r+q4PpN2si8/5850w5bEygp/OaV5IWpq2q3PEg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 6:hwncmRAd5M9nN7MqrMLUGWpGP4tb2XGvVMGNlbNc5R9XcpRtL0D97wkXWzi3dXMY8Rjmv+pxopSheVbJPIe2Z4j52Zm7758ze0JXaYWh6rSt0Hmt2L/cAX/XnCN49s5sBDQAkg4y6Y2jVQ5qV6gSOL3nDRGeZlt2HAQXQ7gG9mPE9yfg1AeNnVaGP85fZHTUdvU+PFderq0RA6Fcc8cWBlaDhseAIwAmHAxQc7y5yAH4O/oYkmyVYcmTqmOj5pfW+HbRZVfB/Ko2AxJ93Y7cteliSCn3uCVbjZ4HHsA/jqSgJkZKRdhX+NmgLLTNOkGr; 5:CdFM/+DCASqYRyORjWL8HBROphEBOPJQ3okMQHZ0a0rOsSIje0fcggf1rc1i/PFR6FFOC4nWOHZzcgo8duU1EvdFdPj585Gk1uySJFWk5dRJLGkpAwNBvwMZF4p4e8AUeA+/u920FEel3bJVGGcOJhTB/OGQqXSgCC2XSfGjblh+mUUPJFekPUjkRBT3ogsv; 24:INwgRzwwfHj552ocCy7rCRehkUNc6Jm0LTIeKeWNmVTlUzXRnYrPfs3qY1ZxqALGRY5OKkmUIfDjsKLdV9jWZw7TSHGwE5+MpOvpYdy9X4E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 7:UEkxx311LerwbhVpaSes0cev0MilWx7aYJa0s7AKcra4PBiPPpJvSaEPmd9y2CaSw6ZYrYSFJMRLyxeqEYdvdp+Tr4mnvSdbwgO7IPZyCMCyMpxLqGYvoLVyuhM2YprHrCIn7Fs0toIwIxrva5MuFn7RobE1FqjR4HP8gndvWXM65nJFxkzkqkRUKssFt5InnkSAvwRsQlK0DGNwTyDuSmTDn9fL5njSXxZX/iakQKkJwWOhgxHvqhOj//a2vpDVLf73fvejPRguhHzubQ8bJdkErLZbV1zDYgZiq34PM46ygptbP1s0+PIlxeaVRKH4B1zjLzBe79yGm4STWd9qcpkC12Q0u6KM0BJkYlbCqqQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2016 13:44:26.5090 (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: BY1PR03MB1420 Subject: [dpdk-dev] [PATCH v4 03/17] eal/soc: add SoC PMD register/unregister logic 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: Sat, 15 Oct 2016 13:44:31 -0000 From: Jan Viktorin Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC (on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the registered drivers. Test case has been introduced to verify the registration and deregistration. Signed-off-by: Jan Viktorin [Shreyansh: update PMD registration method] Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- app/test/test_soc.c | 111 ++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_soc.c | 56 ++++++++++++ lib/librte_eal/common/include/rte_soc.h | 26 ++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 6 files changed, 200 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_soc.c diff --git a/app/test/test_soc.c b/app/test/test_soc.c index 916a863..ac03e64 100644 --- a/app/test/test_soc.c +++ b/app/test/test_soc.c @@ -75,6 +75,108 @@ static int test_compare_addr(void) free(a2.name); free(a1.name); free(a0.name); + + return 0; +} + +/** + * Empty PMD driver based on the SoC infra. + * + * The rte_soc_device is usually wrapped in some higher-level struct + * (eth_driver). We simulate such a wrapper with an anonymous struct here. + */ +struct test_wrapper { + struct rte_soc_driver soc_drv; +}; + +struct test_wrapper empty_pmd0 = { + .soc_drv = { + .driver = { + .name = "empty_pmd0" + }, + }, +}; + +struct test_wrapper empty_pmd1 = { + .soc_drv = { + .driver = { + .name = "empty_pmd1" + }, + }, +}; + +static int +count_registered_socdrvs(void) +{ + int i; + struct rte_soc_driver *drv; + + i = 0; + TAILQ_FOREACH(drv, &soc_driver_list, next) + i += 1; + + return i; +} + +static int +test_register_unregister(void) +{ + struct rte_soc_driver *drv; + int count; + + rte_eal_soc_register(&empty_pmd0.soc_drv); + + TEST_ASSERT(!TAILQ_EMPTY(&soc_driver_list), + "No PMD is present but the empty_pmd0 should be there"); + drv = TAILQ_FIRST(&soc_driver_list); + TEST_ASSERT(!strcmp(drv->driver.name, "empty_pmd0"), + "The registered PMD is not empty_pmd0 but '%s'", + drv->driver.name); + + rte_eal_soc_register(&empty_pmd1.soc_drv); + + count = count_registered_socdrvs(); + TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count); + + rte_eal_soc_unregister(&empty_pmd0.soc_drv); + count = count_registered_socdrvs(); + TEST_ASSERT_EQUAL(count, 1, "Expected 1 PMDs but detected %d", count); + + rte_eal_soc_unregister(&empty_pmd1.soc_drv); + + printf("%s has been successful\n", __func__); + return 0; +} + +/* save real devices and drivers until the tests finishes */ +struct soc_driver_list real_soc_driver_list = + TAILQ_HEAD_INITIALIZER(real_soc_driver_list); + +static int test_soc_setup(void) +{ + struct rte_soc_driver *drv; + + /* no real drivers for the test */ + while (!TAILQ_EMPTY(&soc_driver_list)) { + drv = TAILQ_FIRST(&soc_driver_list); + rte_eal_soc_unregister(drv); + TAILQ_INSERT_TAIL(&real_soc_driver_list, drv, next); + } + + return 0; +} + +static int test_soc_cleanup(void) +{ + struct rte_soc_driver *drv; + + /* bring back real drivers after the test */ + while (!TAILQ_EMPTY(&real_soc_driver_list)) { + drv = TAILQ_FIRST(&real_soc_driver_list); + TAILQ_REMOVE(&real_soc_driver_list, drv, next); + rte_eal_soc_register(drv); + } + return 0; } @@ -84,6 +186,15 @@ test_soc(void) if (test_compare_addr()) return -1; + if (test_soc_setup()) + return -1; + + if (test_register_unregister()) + return -1; + + if (test_soc_cleanup()) + return -1; + return 0; } diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 11d9f59..cf6fb8e 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -171,8 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07; diff --git a/lib/librte_eal/common/eal_common_soc.c b/lib/librte_eal/common/eal_common_soc.c new file mode 100644 index 0000000..56135ed --- /dev/null +++ b/lib/librte_eal/common/eal_common_soc.c @@ -0,0 +1,56 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. All rights reserved. + * 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 "eal_private.h" + +/* Global SoC driver list */ +struct soc_driver_list soc_driver_list = + TAILQ_HEAD_INITIALIZER(soc_driver_list); + +/* register a driver */ +void +rte_eal_soc_register(struct rte_soc_driver *driver) +{ + TAILQ_INSERT_TAIL(&soc_driver_list, driver, next); +} + +/* unregister a driver */ +void +rte_eal_soc_unregister(struct rte_soc_driver *driver) +{ + TAILQ_REMOVE(&soc_driver_list, driver, next); +} diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h index bc0a43b..d17b20f 100644 --- a/lib/librte_eal/common/include/rte_soc.h +++ b/lib/librte_eal/common/include/rte_soc.h @@ -51,8 +51,14 @@ extern "C" { #include #include +#include #include +extern struct soc_driver_list soc_driver_list; +/**< Global list of SoC Drivers */ + +TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */ + struct rte_soc_id { const char *compatible; /**< OF compatible specification */ uint64_t priv_data; /**< SoC Driver specific data */ @@ -135,4 +141,24 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, return strcmp(a0->name, a1->name); } +/** + * Register a SoC driver. + */ +void rte_eal_soc_register(struct rte_soc_driver *driver); + +/** Helper for SoC device registeration from PMD Drivers */ +#define RTE_PMD_REGISTER_SOC(nm, soc_drv) \ +RTE_INIT(socinitfn_ ##name); \ +static void socinitfn_ ##name(void) \ +{\ + (soc_drv).driver.name = RTE_STR(nm);\ + rte_eal_soc_register(&soc_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** + * Unregister a SoC driver. + */ +void rte_eal_soc_unregister(struct rte_soc_driver *driver); + #endif diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 4e206f0..a520477 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_soc.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 diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 22b5b59..ab6b985 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -175,8 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07; -- 2.7.4