From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0058.outbound.protection.outlook.com [104.47.36.58]) by dpdk.org (Postfix) with ESMTP id C858B58F7 for ; Fri, 9 Sep 2016 10:44:48 +0200 (CEST) Received: from DM2PR03CA0049.namprd03.prod.outlook.com (10.141.96.48) by CY1PR0301MB2010.namprd03.prod.outlook.com (10.164.2.16) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Fri, 9 Sep 2016 08:44:47 +0000 Received: from BY2FFO11OLC011.protection.gbl (2a01:111:f400:7c0c::150) by DM2PR03CA0049.outlook.office365.com (2a01:111:e400:2428::48) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9 via Frontend Transport; Fri, 9 Sep 2016 08:44:47 +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 BY2FFO11OLC011.mail.protection.outlook.com (10.1.15.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Fri, 9 Sep 2016 08:44:47 +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 u898hoYu018305; Fri, 9 Sep 2016 01:44:45 -0700 From: Shreyansh Jain To: CC: , , Shreyansh Jain Date: Fri, 9 Sep 2016 14:13:46 +0530 Message-ID: <1473410639-10367-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131178842876971483; (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)(50226002)(2950100001)(106466001)(5003940100001)(36756003)(305945005)(68736007)(8666005)(356003)(7846002)(2351001)(229853001)(50986999)(5890100001)(76176999)(92566002)(81156014)(47776003)(8676002)(8936002)(81166006)(626004)(105606002)(77096005)(5660300001)(189998001)(4326007)(97736004)(104016004)(86362001)(586003)(575784001)(87936001)(19580405001)(33646002)(85426001)(11100500001)(110136002)(2906002)(48376002)(50466002)(19580395003)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB2010; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC011; 1:Fmku0snwL6NPTGcOb3zELwCofXTKeBVj0n8eOPU8BjQAnbQ0+fXjw3v+H6iIggAkILGMc4Y/m4WyH31CHkI09y2B+8Ft3aZP48bn4rTTOIoFxZXk0lFDEEKeixY2C2HYAKjfvgXdo+zbk5BXx31iFwCGxzm/xw/ggg58PHbLukm4reqT4/TfRSzuf36h/SMr93HkFf8ylIsNZo9IdE8H7L+J4Tw8+HLGiHL0kgKM5WgpPvgtu5Y+A9B7gwHxhVWGeYnN3j0Ql42VzXjbH/HCIzwIuqjCJA2M2TrjZhvC+nkm9bGE9whftrvV5ZwEuCA/HDM6JVFYj3J/JAgUj1uQp5T2bSApkyQJ9BekDJC+N7zWOUQPL/jBXrQmIk1c1LzpOf+IznesQQPmjjQ6RfYREDIrgoe3jEjzwfA2Ci9Z8S1dMCHTMDedimD5dSQTZjKM++8D8TiOw564tk4gKdw3yrCeW/4sqHxa2eUdq8iONigpI1OMDzJJts3rnABJkDtXjyLglDDOjXt7gOVlehzWEV1aznW1SBwDSvJ/DhqDyQ4FPyQAaCIA3Y5x2BvQxXOm7PT+UYyUIYYvzObDkTJh/CvzjsedeYvQfHEj3qgzh2ZdKaBy0uRc8XAbeeTrp0TTB/z+a3qWo5NMLCrxBRsBdBhg1dfnBzNCHoyPRWT9XLA7FWgVkbV/CN6FVzff/h44OoxkGdULkpdHEvCl8njgRgVcQpJ2C7sklajAFKOco2U= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: cb2fc8e8-9a71-42f8-89db-08d3d88d8e31 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2010; 2:tiMy4O8jLuKoMblyJGMd40tDgzUx0zUNFyOs0izmOp7Abk8Y3QK3jWZphS5s3G1vzBFXkMqTvGGgO6dKjREVUfyBPQd5u0MO4qs4fCLOQxJFoW0b0UwdMF09UfDgtVydGDmPm4ASmSgKqlBtFS5VL72qdveusOSa6pg0n6R7ZgfXJbiQ071Gz9BxiXZ/H70d; 3:Xeh6wiHxJQDxsPlYD0ImUM6afni19Rl4no+Qj/zz0/H8H8JjJylonCg2VQPGL05NvHpS+CFQzMElCDMkaim1Lc66AiaOv9e7FZM/c98ebHeLvBQ7v8Owy3xEktQFmtRKcGm6qEE3y1Dqmh0HuvUvrFPjbpra3E3H3l/uvJdXKrvJPK6SKJ/MIJ6R660QrfLHdtqXBYNxNv0iQ0xFJHqCHRES03iWzaKucPpkD6k5C1o=; 25:lich6U2ejS5PprbCdUBiFpwm3xrISF+1821dGQh2bdaxoVM22kLQACJ4I/E3AefBtSGHHPvMrKBQpq7VWnPkJxaBUOoXysAQ6SfgrGlXhzGFI1BNN4NW+4Pg9PhFGycgrq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RpjTIBToNqtNEZFCxbKmD/gFHvAHjwRlw5226ub21J9vtfSPN9CfCnprDVl9LyhcRFx3B6/uAwYZQ4t2DwP/NLmyixW3Gth1mbb0KnyA= 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)(13017025)(13018025)(13015025)(13024025)(13023025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB2010; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB2010; X-Forefront-PRVS: 00603B7EEF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB2010; 23:omfGyVKljJiKhk5dZ9n+Jgu5QjqV6w/qncm19gX?= =?us-ascii?Q?yc0pkftY83jZuBNY9ORZ+bzeBB0T+tD9TyHxFU917g1C/Cw925hR3z2P1P+S?= =?us-ascii?Q?p8qC1nucQuHj49oPYaYujxLWC14bXHTr9LM7Clmn1PzxaJgrlrRXy2rcH4qq?= =?us-ascii?Q?kdwpXlmu2TTslM8FY14qb7nye7Fwl2k7NIICt6oGZO/G0GrTIBD0SR1uD7wV?= =?us-ascii?Q?t3p5058EQZu9LtjeBYDZVRVVF5BYSPg2vjxpM7X/IB19eBeermqsvrgPvIZA?= =?us-ascii?Q?Qn5MidGZNvqruVdjomjJPrZRYsNNjeRnw4Frqw9V5IirAxxqf8OTjRgEeCMC?= =?us-ascii?Q?gQwn7zqOHfiqAu6xTAz+/ytIkfkjVsT84lg/3KObJ9IIgx4UqlAjoSbgPPHx?= =?us-ascii?Q?UnsdqO4w/pPPq4ud+N9lH2oIg1pxvqOitmQIWjYj6TR+yEijsj1pd9Jr4s7N?= =?us-ascii?Q?sYZJibG/i4fIyXLSwwMiFdyyt9ZRN7sOG/WfyiDWHTFptQwb9wv6dntqxrSe?= =?us-ascii?Q?F8nE5B9yE/GQpV06KhPDkkivVd1H5FLRtFnoYbQ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WgWgku4zx/IyQIW/tXI7GIMDStvry+zJqkK+X2pcO3qaCeRvd+olG6C/llS2hZi8uWejw6zHS+LrtSMGB3K1fFk2dMBtdFOPeHDr6CY2AnGm1KBb81wrehz/abIRts=; 5:RDDLy4ywpyKKdRs496M1ufhH9No1ahAR5G5ppt45wNAM34gwR9/Z8vY4pMCALd/KLjICKqcXn2713wd0AJTSNWegiKE6hqmnbpPa3pnggT/6vOgpXDJb9ynqp8oYYTBXSURz67okFOCa5pIHTBnhrgYn9EdA7s3JmXrfdbQMUmU=; 24:G00kG5AiZ1SIyMsNbrowGlJhXeDa/628AX+iGTG9jaEyYCwV3frwof/3A7kGDci0k3tmQeMadCTlZ0F1Qou++IpBR9rJwt4mqt2/dPWO7gE=; 7:wpM8h0zEj/lf0vt/C5JiV7Qx3/Rs4DkzU69b68MIKNb4dkedOtgngw6PJbxPcHDxnJQxeRgoKAq9kYl9lXt51D5jykETRYrCDT8+ti9CnEStu7pxg9pQqlHWfQQU8cxzXpBNuMXPronSsti/PnUUQqBes7gUx5yIgg80/5Hf+FT0KOQ+/7B4uMnnDsnJ6wmyOeWmrzkqQ3VLFdo+0z/I7IaY9dbSR9647YojIpKsD7/0sQOLbXNKZ/dlkYBvveNf SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2016 08:44:47.5099 (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: CY1PR0301MB2010 Subject: [dpdk-dev] [PATCH v3 02/15] eal/soc: add rte_eal_soc_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: Fri, 09 Sep 2016 08:44:49 -0000 Registeration of a SoC driver through a helper DRIVER_REGISTER_SOC (on the lines of DRIVER_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 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 | 4 + 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, 201 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 7b3d409..cda8009 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -168,4 +168,8 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; + soc_driver_list; + rte_eal_soc_register; + rte_eal_soc_unregister; + } 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..16c5a1b 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 DRIVER_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); \ +} \ +DRIVER_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 b8bfd4b..66c1258 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -174,5 +174,8 @@ DPDK_16.11 { rte_eal_dev_detach; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; + rte_eal_soc_register; + rte_eal_soc_unregister; } DPDK_16.07; -- 2.7.4