From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0041.outbound.protection.outlook.com [104.47.41.41]) by dpdk.org (Postfix) with ESMTP id EE85A568A for ; Mon, 24 Oct 2016 13:59:27 +0200 (CEST) Received: from DM5PR03CA0024.namprd03.prod.outlook.com (10.175.104.34) by CO2PR03MB2376.namprd03.prod.outlook.com (10.166.93.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Mon, 24 Oct 2016 11:59:26 +0000 Received: from BN1BFFO11FD046.protection.gbl (2a01:111:f400:7c10::1:144) by DM5PR03CA0024.outlook.office365.com (2603:10b6:3:118::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16 via Frontend Transport; Mon, 24 Oct 2016 11:59:26 +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 BN1BFFO11FD046.mail.protection.outlook.com (10.58.145.1) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Mon, 24 Oct 2016 11:59: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 u9OBwEMR008267; Mon, 24 Oct 2016 04:59:23 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain , Hemant Agrawal Date: Mon, 24 Oct 2016 17:29:26 +0530 Message-ID: <1477310380-17944-8-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> References: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131217839667243116; (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)(199003)(189002)(68736007)(5660300001)(50986999)(5890100001)(5003940100001)(81166006)(47776003)(48376002)(2906002)(76176999)(106466001)(2351001)(97736004)(105606002)(11100500001)(229853001)(4326007)(50466002)(575784001)(86362001)(19580405001)(19580395003)(586003)(189998001)(77096005)(92566002)(626004)(50226002)(8936002)(33646002)(305945005)(36756003)(104016004)(356003)(85426001)(110136003)(7846002)(8666005)(87936001)(2950100002)(6916009)(81156014)(8676002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2376; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD046; 1:Xt97PeDnJaTlF/rJxTE2tQAgHs7ij+46Z0N2A0g0TZwfHZfvskLYOUcrzxDNO36LSVOZaqF8nkScjJBG1hhS2CEW4odqDKfvZPZQ8xQWsZ/EBvPRkstnRx8vODeryfBlEbQ7QR4F8Cnoy5lpx2no1pImejLqvYwUdsCWRdjhqSYP8QEkM1JBY4FpFRa+1FyEPlKXMUSa8Uv3gd1MVbd6ZvY3xeEQ8s33CUhnosJBcqtqdD3tOsF6IMd6Fzmu/GIbRDLcQbjBrao3UEk2OqDga3foqYhuYf/6IUxjSk1O0cmyx/WtdAYVimwueCI7xq8aVnXZ4FfRe3NtHJCsPk9f2y3kVHBvVA5Rm4+wS/rSefGu0nCZrDTYR1bmnJikuNH57JXW26qddd8jEfx1/WQCjH4bTzfxuVUab3Cy/4Pg/1keKMpVsrlQohNzZlbsoGB4USTsiz5iwv45e7uuTH1nirm2lTzKdwU0OwMPszntnuAgx3HBgak/PNd8f9G6UxurS2Mpci7BcrttJ8o7RLUeYbdkNLiMmW1zzg2JhB0m2yTUv/hA78hqL8qg72srGvGQ3KAhP+lIhIUrZdr6OsAp+LlV6+Clu92LqeWr3B3VFYrnwW/bra/AYO9XzzdMM6BPXSI2aL17Yl+jb6N2vxQrHtikK1Y8wXd2eYcMOA0EUhYBq3WLpfXnc75mniuHyUSRMXRhqIUZdAw122efRAfVR3aI1nQSg7va5g51AD9v01U= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c4b06954-ca95-4d0e-070d-08d3fc053404 X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2376; 2:xyvHthkpUa2izJ/3bRlgOjRg3UZvz5DWs8tO6wD0Y8twaCZEpmSru3HXAxhbiEINJVDCu19JvEvqB7Mbo5itamEJKA4plnwWBCvsWNkz7GBx1KyKPVsCCxpzD9FcJnRMTfgnru/O+Xe65x2OQ4HplaAD2H/gGdVlP5atYfDiFhkd+0+hNyZbp2V/MPXl2UP650JHZ6EfNrGrj/bXGprIOA==; 3:z/t4mXuS7FL4QcjDHDunz+lqsR0fyEZoVNH0nbrL1cxrHZ1CHzDxqKu10iZ7SVJT2SiLrsgPfRASI7ZAga9rvNjY0CWATyuHL6SF8WC0crvyps3JCVaSsqkD43PXAF/kS54oLKsBBtZsTUjPdyZzH0O5BYYdx91fHfRKy+hf48uvBY/iHD+ONePiFyiKxLTln8hXRdb8O5txXMWQAPBdrPzHWFOhBtRMD9GXtjNWRcQVWbqO27tNn8MTRiBVN+AU X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR03MB2376; X-Microsoft-Exchange-Diagnostics: 1; CO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orRVpFXEWITV98ZaRsxNVyj64t9H+l2uyErFNGcElWKp1ppUZys1DqYu1wNLTfP/69Ijgid0xXzsTY0aub/YXAM5XcFfIxw==; 4:HCT68jgAylf19u9MI5+6b39ltc+L6WjGNvMqD5zeU90gPiEgwhcdgYu3ZoVv7BztB1AaZqYtxhokMRoXQrqXgVR96GG6sqMit1ZCXMSTG+AlpesDUhb/Nj/RJ8n/TM9wFvGmJDv+A5HZLFcCqqqAgtFpXQVAeKHtB7R78QqYW3lO2riLsOuPgL5dahaP/E8vhz86ftuWP+Fsc4aXpvd9hwhQX9cHbRokc8y4Jd42b8LwdHcOy+OrMP7ZCkB3nf8cziFawroxcMiVG6gvg67BNCRnKhlrnPLm18axr3agI4lt7jGEJA2xdN3sMxu3eGuF32IWwS07cootm+ZG6uIVuGOoZB9J3twxFs0LtwK6jeWjJcO2Zr/H74quGiQncTXGFSmw6n5eszb5wd4dMiHpfF0EfIkXJPSNvmi4/1ZoCxIOwOVgLd0Zn5IcbV1HGFLks96coki4fSaQHyrns8Jpn1cL5NmuV/aIlZzOhKwPdv/VgitNeUFXvm91zeXRpcd1TsIjhmHDcdMlrKxflGOJpOp/rkLlSZRmIo8o/ZBgvrZDw2IEQBv7kHQ8ZFeFgeJC 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)(13018025)(13024025)(13015025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CO2PR03MB2376; BCL:0; PCL:0; RULEID:(400006); SRVR:CO2PR03MB2376; X-Forefront-PRVS: 0105DAA385 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2376; 23:Y9VYARBFmzavQ/GromwXD0RBRpTa8JQXYAtj5H9KT?= =?us-ascii?Q?jwov6M49Js/8uvJrjGCJa7ssA7MEG35h8Xzsr4DNAJ4GjOF+/onuA0WDyU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wZHW2bzf4+3B6dcpwgp3rLw8w8S53eRxqTwn?= =?us-ascii?Q?4qbUJHpjDmQKxNwErHjNWFrhJcKUoAJzivunaz6XxtdyjMU344KiPofaWobG?= =?us-ascii?Q?7k2IFSB0DEq2OrfNBU1wc5orsDVY2DD9B8EcKfLTqL+s3ka1GHS+6sHiaE/G?= =?us-ascii?Q?JwxTME7j1Z5JaVNzaypP6NmEYwh4eIR9SZrhs2l7b+lmOeBsg+iJCB23lV5N?= =?us-ascii?Q?ZmdhHBN7BAAFHu7lY9ylhokainhyfP1+w+easmoWDxu9JaVPdROpKQR+hYC6?= =?us-ascii?Q?6Gx6FBe/YmW5Bdon18=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2376; 6:zMmoViY8btbnxgMbL3t/hrgKd6NIKXSM4DXr8qgXpSYqkAWCOUx6/zZnhoCaI+gvlpXZZbDFuAlWsfCweJsCWMyBUNFUAqbCmrIsr2QrjXzabFABAo1IIfiINAochz1F+srZu7d96L28Rip17G0aq/ZoSR1c/dr3HSuQ5FBbqKzht+OyHqMj+6+IUBm40sQEiMWF42nXEISCAqhFf8zhsyAI6WdO+Pa8KhieEHdK/gMd0p4UQxvfYcytTQ3zgO4280A6Y6qu+H02dXPKdq1d1E6QcYz9sRW2L6efQOFpjz5ZJdqA/YyEHg2NfLvBnbps; 5:qlFwGF4bUH7SeIMpemVNYRNQv2WT+pEH2Bec0CxoKegnBN5s7lswjTo4a5//DkQPrzzz6V4e6ySbKjsbsvcIpDlFzhJsCB02GU9+E61UPpNjyG+kDygrLDnif8gHK/OW4lsbZauo6gmYeW3tFjbluYz4WuF903bD/um2JTTbuDTlDt8To1j6GFFf+HDQQyeu; 24:UdeeXo5rXi8UTAM9tIGr61eyUzgfEYctWV806Ti3ZrC6EZmY79JY4oD3ZX2EVjpTy/bdU2mlamsLrNQyWqdGPA8xMaqI+yuuc1hcf5p2BVI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2376; 7:3gE3LK0Plo14fiY51ns+Hf7Qf2hwr1ukt8Y+X8+eBXXcsfJTTGrtM6Sbnb+lxLzRgzcdTLy26NzHd1UuwHtwxIk+i+7YPbf+tCHqg8+9IJld6ES6fZHY54R8ZRWCDwpS5lsCu5+6TAYuYxCGCWbb7z2tXlrenAEsvXBSXgzIXpMsyXW5828jqw29hLBXrjhILynndGay9P3PxYbClQjceoyA76+xmVl0J74VCFnvy7/UQCQeiWQXls+v4iXYhkRx5QW2z7GrCfihLY5sA8nDaon6SqqWTXB+TMppQGxMaM/JInQFp6SXw0oed0agk0payS4IF9syt2PEAeld4ux9b3vo2UQPLQoPYRfTVOpnoyQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 11:59:26.5215 (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: CO2PR03MB2376 Subject: [dpdk-dev] [PATCH v5 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: , X-List-Received-Date: Mon, 24 Oct 2016 11:59:28 -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