From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0063.outbound.protection.outlook.com [104.47.41.63]) by dpdk.org (Postfix) with ESMTP id 6688437B4 for ; Wed, 31 Aug 2016 13:01:36 +0200 (CEST) Received: from BY2PR03CA065.namprd03.prod.outlook.com (10.141.249.38) by BY2PR0301MB2007.namprd03.prod.outlook.com (10.163.196.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Wed, 31 Aug 2016 11:01:33 +0000 Received: from BN1BFFO11FD046.protection.gbl (2a01:111:f400:7c10::1:112) by BY2PR03CA065.outlook.office365.com (2a01:111:e400:2c5d::38) 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; Wed, 31 Aug 2016 11:01:33 +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.587.6 via Frontend Transport; Wed, 31 Aug 2016 11:01:33 +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 u7VB0laT010481; Wed, 31 Aug 2016 04:01:31 -0700 From: Shreyansh Jain To: CC: Shreyansh Jain , Jan Viktorin , Hemant Agrawal Date: Wed, 31 Aug 2016 16:30:23 +0530 Message-ID: <1472641235-23626-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472641235-23626-1-git-send-email-shreyansh.jain@nxp.com> References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1472641235-23626-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131171148939986014; (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)(86362001)(229853001)(575784001)(48376002)(97736004)(2351001)(106466001)(33646002)(50466002)(105606002)(189998001)(110136002)(85426001)(50986999)(36756003)(76176999)(77096005)(5890100001)(2950100001)(5003940100001)(104016004)(11100500001)(81166006)(92566002)(626004)(8936002)(305945005)(586003)(5660300001)(50226002)(8676002)(7846002)(2906002)(356003)(8666005)(4326007)(81156014)(68736007)(19580405001)(19580395003)(47776003)(87936001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB2007; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD046; 1:5yW6TccB0eQ7P5Cck7UuLPqNEBsCuD2CXHk0YlUfyrs7Vq4lgkGC15xA34uwISoh38hCRj0sf4Sxskz6nOM2Sj5AdneIxtjWWhV2ZOS8UF1v4pA3XIVlvjY1c5FFkiYnG0O5cbf+JoSZE0QR4zkGusKFzX+U+VnZnUuwVdCvR7/A6LN5ypCDg6PwFYsFuBGtnkLmS6kaFhjdzs2A4xAmIyr6vjN2WU0/ImBYdaJ7NwDqGobOSQzcTpitFxsAl3f7zTcISf+Glb0okShaiZfVPTGGURFxYvC9CFD81cg+Z73IjOCx6cdJb1AE+5jn5OnL1jLtq8jhh/xv4W8Lbi0f4wXpNNXWf2cb3RaT77XyRFhvY1OvtqwMeNEi+2rZnc4FclHICf0N5QkdufB9uIO5Q7icPHNyovPcc14/w8qo6S/uDrN26Za/1J0hH41SkA2FeldUBuE8hrIuc6OVoM83uBKJbP1rfDJKtBaEIatjuwA0tT1e5Sx2yaCy9v5CEiigRU2TDgT1xstwvYXtR9L3xhMJ5gfBffqgkYEAl31qVX2Nmr7jkbGM/9l6B0C+lIAv/w1sDB8JpoYB3M8VVKdXVKt1eQ2Era/kLJxweCSUBKm7WQxzPRoVoHn/FEBMkoh8JquDz/QmJgIpUCbOztpX/DI2jytC/PjqSp4RXQJT42HKYyFrV95BfwP6rL8A+4bxLgXEmemGGMwKxljXV5F/SMKESEl5+khONPK9JForh8w= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b84fb4db-aa03-4632-f966-08d3d18e2bbc X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB2007; 2:aHJlApBp/LK/9rGLNkC5rF81i5zu38d6XMXibXjMOLDM/4HtzfSvTg5ED2QJ54JDE3L7a6kM1Tdh5Z44X1kXWZXw9bzd+ViqOWLINtX02LDC2VXPe8Rb62pIj0HmHpcI3uevdoSabbPlHetvwWKS/xodwWzrrOoemgt88qluAsThUyspFlueGSQdJcOV2Sci; 3:J+pg/2SspzN92Yhwv4aSJ+S6ImRMlTGVIwOC+AXWTmd+9pFiTR40VZnWuYhgVQ/muhe34xr4QD1D450BkW6fUbBOcEiC29pcrXgRNMb70umko0XOay4KjH8SNPOWU/qm/gT31HErTqitixFlNoQatXKIKAjdGPPmswYJTfZiqOc3BSiVvfbA21m4Z2y9qog/g2WVTJWmvB0JyAUnZIJwcIxl+vAHS9i/5vJWLG4FGlA=; 25:NKrmDKHW0s5b3q7d10XHOWTUMQP2FMTGeHJDFKoVYL5IlnlIw3GcdHOWsMEltULGpSvsVI1dFAJsb5pDoWqEvNn165kKy3cPyWPktUM1EolTNCJxZ6zclnd+XBpw0eo4CKFp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BlZb6FlajY7lV0JYwmou5xLG7XrH4dOngXhuDaogKYNv4GmInqJxwRhz8ijlhIXvxzkmYMOhu8z3M7rvtPFL72i1KYlPT02gSTe4uiQDNfRdW9g= 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)(13015025)(13017025)(13023025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR0301MB2007; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB2007; X-Forefront-PRVS: 00514A2FE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB2007; 23:gHLvDVZEESbTilWxJtJJiGLPUJT9V2s11zGJcJi?= =?us-ascii?Q?2XhSFry0SOC/PiW0u7/qH6UKUtzEYxMEmXIOhvf2Skv4E3koS7+LWcOe9yIM?= =?us-ascii?Q?fK3T2RHTxZzEKKAU0vP3xCT6YJH1/5xyjGgjD3u4w1YIVMjVJ75S5lw3v0i0?= =?us-ascii?Q?Aqk5h42BhbJrtnJwTCmLssdpTGxha1V6kxgiKP/EswD2uL8KAaMn4e7C5uwA?= =?us-ascii?Q?37V0MD/zQqU+ixyJbpg78EEtzsKeXQbTPMG1HLPriRK86pJP0BM+4T9RVzFj?= =?us-ascii?Q?6/qo2sLFZNkafqDKW3M/Meq+duPQiKODHYxDH7nKRCmt3Ug1xYAFvnhrjHcE?= =?us-ascii?Q?yrwP9LMJX5AfsZKP8aGctUxEvbRqCB/ppNV+gVKt6pwlw2DjS08PULvq4wun?= =?us-ascii?Q?N1Mh9/Y82vUBbELCbv2sIiL+yRWKF1wWfv9clCQxFkQx4sKT+LUeftXTBK1Y?= =?us-ascii?Q?VLgrEtyeqCEReYlIaxnZHIu01HbN2v7QnRSb6iagv8YLDiwFqCqXRVU8gRvv?= =?us-ascii?Q?0gerMjKvo8GPNzJg9hXn/yAlN1uUz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OLpnCpWm5wok26yl8HqD/ks9O7uf0VnY1RyjK5qdVdCGFV8qa92aJoo9KiV23a4yiyDD/UkFExr9rDAp7WW3tZqe3qtWWPTx+44laozjOrTlciCkpqqJklIkeP/GeHgRMc=; 5:wt1JB3gj3ebe7+h27Yir1V9a/4sEzv3jw5eYIQNkFm5Lg6DmtNanEg67jzRsHUJSLpRqoqg1GWyFv2i2qY0xbtGueyi9we65R4twAW8KoNHgq9eMy024IFHsyL8P6uMgsyt2FaccrteNtEHnSAPupejyFfUgGaGyhH2RE+Hnp+0=; 24:+4pj+420dvHvqN+hOeF4xuST45dPS6Z7+nO8dsQTuZD/cNITD06I9MyEuIn1pUdvQmaFDYrWIi11McOcC4LrCOsMigNg5cnmZgpjOErlZYA=; 7:aUuilZ8ReAPKouWepp3QDIk2rJEgVL2VRKUzhi23uOoEhQMOzOmQtOGYHMOvqQWe8CPGwp0zJVqjzEaUCJyLUoos3tFVQ3t3jMMuner6xLPkoaHKIhoFXoGSxa8mnBTZ9/B+mBirnUJUj5SJQ8VgvpKl876WqiyY5cL1fi3aSXKe0aOfhHGDWqoAQp5IV9AhQhQV53X+5MUA6tJ0/wqu9qLJeioYYRpNaMJ2efHzdmN3W6QPK5oGIP2oxPNIJYz9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2016 11:01:33.6866 (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: BY2PR0301MB2007 Subject: [dpdk-dev] [PATCH v2 02/14] 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: Wed, 31 Aug 2016 11:01:37 -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