From patchwork Thu Oct 27 15:17:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 16823 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3865D58D6; Thu, 27 Oct 2016 17:17:48 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0067.outbound.protection.outlook.com [104.47.34.67]) by dpdk.org (Postfix) with ESMTP id 597BB58D6 for ; Thu, 27 Oct 2016 17:17:41 +0200 (CEST) Received: from BY2PR03CA062.namprd03.prod.outlook.com (10.141.249.35) by SN1PR0301MB1629.namprd03.prod.outlook.com (10.162.130.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Thu, 27 Oct 2016 15:17:39 +0000 Received: from BY2FFO11FD017.protection.gbl (2a01:111:f400:7c0c::167) by BY2PR03CA062.outlook.office365.com (2a01:111:e400:2c5d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Thu, 27 Oct 2016 15:17:39 +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 BY2FFO11FD017.mail.protection.outlook.com (10.1.14.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Thu, 27 Oct 2016 15:17:39 +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 u9RFGIfb027183; Thu, 27 Oct 2016 08:17:36 -0700 From: Shreyansh Jain To: Date: Thu, 27 Oct 2016 20:47:33 +0530 Message-ID: <1477581467-12588-8-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> References: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131220550597665907; (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)(199003)(189002)(68736007)(97736004)(86362001)(11100500001)(81156014)(6666003)(36756003)(626004)(5660300001)(110136003)(33646002)(104016004)(586003)(76176999)(189998001)(5003940100001)(4326007)(305945005)(356003)(81166006)(8666005)(8936002)(50226002)(7846002)(106466001)(8676002)(50986999)(50466002)(19580405001)(47776003)(2906002)(87936001)(19580395003)(48376002)(105606002)(2351001)(229853001)(5890100001)(2950100002)(77096005)(92566002)(85426001)(6916009)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1629; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD017; 1:/hk4DYhUp+ecRwuWz5Hg577K2HwRmC12scTHwQzc730e4IWGhX7E1BvyRSLfz6v0It3SYexJJNdBHgfEDBOe/ii/kKClAqF2EfUV8QH6TnwVOxByy3ip8by39MrdbvBa5bnaaBrPW1TefXPguCN+KJmklbWC7+5tESGCSDqYI9w09JzOqvVfNu1QBa00LmVqZhj5Y5OxKPZchOodWouRvqz33W7unodfK9xkVqshJDrq3Zoj8JIQqsRFo90+G6pwsGlnaaocXmUjRCt9v1SAeX4IEvvkXmOsKhmEBiZSc8xq8/QKM6js9aVOCowxearIjOPTuWYnMwMyW3WxCj+QI9nP4RtYutf7b78RdSI+ERNYWkIxg3b9a4Cq6gE9kI/t3Hzv1EBxFEHVuwF7GZ9+hnwDK8ErehIiBHs1v3joga4Rygtf46nUdp8qwXW0w35cXPIrbFowXROcyTVpgsqBh0iHtHD2cBE9zgOqge8d4L46xfz408dEo5+QsK5qpzDL4SBkLktLEF9vHL+zVi2KCcLTJ1lUhzrI0lI98/9LAT74td106N4+9DkPZgkWPPOKDzaQMBXMqmH7DJwDYdAu7gNazWIPc2V+02L0liHO3SMVAgHT0LbfLGZE8neSmN6d2mEIR0kWMyd8hzKr+b6qLgwpaxmxxGGtVkHQmZeN5wDntNNGSPP2eBz1RBBB5hwUasK0/RPkxyBRQ7xQfiryHVrdA1WBGdN5oaP5leTl66g= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 4e0e7150-eff5-40c2-e473-08d3fe7c6411 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 2:9MdjyYjZuWVIncmKiHrIdJQXHenVdEVXTTRa8dF17XJV4+SGNZJikNNv+a5glfM5BCsBIOSSTuTPRmmmaoFvfXXvMTsVd6f2VQQkkIOcnNbmWGEuvHYKELiyaMgXU9Qa0+wBWFUwHcGwVg+XJ21ODXW1GBiZLDLdimUdBWsAYcQqIEOXkGBqJwo79p2x5hlywL5x7+NSdnGp3c5Z2GiSmw==; 3:/VJAL8+VEI1Qh3NpamqKJthB0v68lUykNaYCC6yW6CDSORGlfnbQ0R2FRSo3Tcp9eAoyEBqmOOOmW1YI0gxJa+4u79Mz3u5J7wdATLBehR7rG6UKBBpgvVySJMX3AWjkXa9weRvtjTRCPWbIE5wXEuD4Dptm7qSEu00EuSBuCfuALsw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xDWZhYTDki9sJGgEiLN1ABb3wUqoVxedEFE6DnUUuCTYGBu22lbXirRGNiW9BBRIzeB7kSThdj7D2c+0YJmFLsnfVUhjq68a/j8sobRuFuVg4KksYVG3OfdVFh5yCRRnFCxSaX10+U91dq6RWohXXf6YzNqv460HSEbfr2PDtfGQBOTByASnJ5G8khNEk8uIhIBBjEss+U5J3qTcpSlqfZC5Jev86qweDzkXQZaQrRoQUQ9zbFNtXGJzyknmbMw==; 4:VEeNEApcqGLW8CbMr/TQtXP8BifZJlLuNblEU8xPou8zQDmuWNHviOzWWmVfWP00sF+V0U2V8JTJOhnOkSQ1N76zNUVcTfW4N2HjjJO6dtpZBTFDExCZuG1ZZIRPkK2IsyYsNDwBGY9UYh3jpHOIwRvuLFFQ1GQs5lFYwuqPRoSfHQhGl6KiwawSeRJ4RlVL3jiDc/8Pk8Nikqr/Qb/ruzTues36GCPIIIhbP3KFv889GE9Zleq8vkOtgt/Er6byJouHHZfmRtwrp4aINRveXOF/FJ1XOKluiH7K0aUNfFOvLa4J0CMAOfn/cOyBX6gfcGzzCwWCz94BnK1izpXOHL5TmJHLyNPC+W0Rgo0Gt6HrhM2eYmWglMYY/GygYuVDB1gwH+gv6e8k7ucSSxea6Gv0Wtg8kX3RkZLl+JFTIiLXzCCL7ItBv2k06eR2A0SbRr74CciVC61xNuA3jNtWbhBHL3aIardnLWPyuE150UQjzLZ0Yq3QzhCk2vSUuKQ1BYXm8DWRbBCbW+WHw8FcVJ64YB/D7vExNuLQDIDGWAJLLWKPzU3gecr8M6bFBv73 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)(13023025)(13024025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:SN1PR0301MB1629; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB1629; X-Forefront-PRVS: 0108A997B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1629; 23:aIaLC0sMqtMce2IKgbe/d4CsDvacWWZ6FtrhFFL?= =?us-ascii?Q?s9GlXirtEf2q+G09Yd/hbWvfwZpdUuUYkh7cO+5wCYBJuSVmdRJQGkkQJx3q?= =?us-ascii?Q?RmGhJn6Cjoqdg6oxYgSx40Q6MjW+mjuG6scHv7wNC2H4xogYeR5D+3djlPEa?= =?us-ascii?Q?tz1O/aiz2NJvmc4Um7vbcgot6DqNQ6iLbMTkna4MJ59OTiZoz8nlRpNRhrl6?= =?us-ascii?Q?qFrjM6ve3CzDN//Ts8Kuh0pKKS1zplBWSfJLBqLFLqsKbLT5dtSPLXF1RVyt?= =?us-ascii?Q?5DXvcqnAyEw/2Y9fCPz27fPLc80zW0NAApLREkGqZ86eukrq5WS25v5yK7PA?= =?us-ascii?Q?X55wJyJ9rikdDhFgelqZcScG/AZE948MRQZCzrogIukZoBtAqXXvoqq1fFin?= =?us-ascii?Q?cm3iJCe7OyvWF9NFGmKHsITsOiJ7nEv2xkInjuctG0lm3SHMjSXFKZZZ5QwL?= =?us-ascii?Q?jLUdoGoSDI7Po0JorBIZhRXZpa0VsecqqBdx798RZWSAhgo4RZ55I03ak5/t?= =?us-ascii?Q?kojECf1pUs9X8iLAk1EaC7kVtOvbJXaqJhJ7IstEpFhjeaJfJdseygyn7gIU?= =?us-ascii?Q?GTDfbiKt4E2tXVeTpjSiSMe7LUi7X2uiUUYpWsZXyiKBTlCbN50JZSizbmI3?= =?us-ascii?Q?Bql14TVvcIQOzUoaezttBcyTHPwZACbGgzyhsw55b5968kZ4QyNMJygUXazn?= =?us-ascii?Q?DirV5O9PrmS2nel65FfxTEFOIwuiGyODEh0TH7mQaMPDCQyJuTCqbC7jKNWh?= =?us-ascii?Q?tS/IbJtB1+LZ9RReGuINOhU0ss5YaO/a+FB/Yxr1M6dLqzVajLoHJNlsKeiE?= =?us-ascii?Q?Io20d6g/nuvlxKsE0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K; 24:rD7TYkSfuQmkDeJp3GXiC2fmtfVyVls8R+5DU1b0elzLPVqK7dSMhAslQ/nCFFX362XqT/XiRy5YLl5u3HlnWhuplVKeGQUsgU6G1JgNfUM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1629; 7:Ngsd7fLSbvlVswjcd1Lq/fYcLuvi9P1KxV+tci7CpqXlsVEMWQxDsiWZdagQLh/+FTB7ttbgUJlRGiClX0QWMj1H+scD/HEJAwrlOAx89PThIp/M7GeORAgTuSGVp5a3vo8WpoGu5b6NzRKphowleMTEznMSKL7FgnTRuRkR7AdTM2QUlw+uRfcnVA85BS1Q9NkbB+p3AIBbH7Vt+GfJf/zryi1sJPeKTTCOmz3913yBJ83Jw/v4s064CrC9I6uE6MRerIz1/Ue6Jhg/V4ZWgrw46dBrK+us3FP9U7/EnURMcTpdQtcQzxJeJnz5ggXml9LgObYKSaU/HHbEgZrGD6jWcqKFGD+jXyLwmSHo9/0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 15:17:39.5793 (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: SN1PR0301MB1629 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v6 07/21] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 5c32737..23b06a9 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;