From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0062.outbound.protection.outlook.com [157.55.234.62]) by dpdk.org (Postfix) with ESMTP id B5D532BAB for ; Mon, 13 Jun 2016 16:20:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ePLc32eEnfwyH5SURe4cu5Po2RSAd+6jBArA6NcUE2E=; b=m6DQhmIT/Qi+/nZpU3UO0SdnMoC/O2RhvG2loEwZtxi139smYo3qqfKUaQZVSS7fMEPMQW4R/mnT+la51akm8g7lEuyYPLdThobEBbXXCIyuaoSULKYPy35WcogMseFYunQnrtJCMPR0xvjf12N/X6Darvp+IZv8lOM/QS0mdTw= Received: from DB5PR0401MB2054.eurprd04.prod.outlook.com (10.166.11.137) by DB5PR0401MB2053.eurprd04.prod.outlook.com (10.166.11.136) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 14:20:05 +0000 Received: from DB5PR0401MB2054.eurprd04.prod.outlook.com ([10.166.11.137]) by DB5PR0401MB2054.eurprd04.prod.outlook.com ([10.166.11.137]) with mapi id 15.01.0517.009; Mon, 13 Jun 2016 14:20:05 +0000 From: Shreyansh Jain To: Jan Viktorin CC: David Marchand , Thomas Monjalon , Bruce Richardson , Declan Doherty , "jianbo.liu@linaro.org" , "jerin.jacob@caviumnetworks.com" , Keith Wiles , Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v1 07/28] eal/soc: add rte_eal_soc_register/unregister logic Thread-Index: AQHRp55rklRhIkOzs0Ca6x0MTMigv5/nk7oQ Date: Mon, 13 Jun 2016 14:19:39 +0000 Deferred-Delivery: Mon, 13 Jun 2016 14:19:05 +0000 Message-ID: References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1462542490-15556-8-git-send-email-viktorin@rehivetech.com> In-Reply-To: <1462542490-15556-8-git-send-email-viktorin@rehivetech.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; x-originating-ip: [192.88.169.1] x-ms-office365-filtering-correlation-id: 7358a590-c973-475c-16de-08d39395d0f7 x-microsoft-exchange-diagnostics: 1; DB5PR0401MB2053; 6:DW6F8BZ+vBW0TAU7cElIjjZMUuBfLVzFSis1k8n3PEgrVNcuIexhWuE8YLn5pYpgO5+XQvZ9RRacqYDpQTDwjx8PhD9Giv56Jy+xqw4KD4TnDC1O63nT8KZV0h98OBc4gCFF7e4gMpKUK8arb44CziSvqtGugIReExz61YS9PgrztQqBbkjC2H7BxW7G7LnU5SC5KS3f2dqoR3r+9DnIBDyY76Cag5YAU0IDkXe2LHKQB9+oXS6iHhzCxQEfkVxdYcd4vsP0O5XqqOjvLAjkZKh82N9cOoMczGj9j3wRIx0ZAZcAr/YD1cMmDMbQKZwgQ5fTUbFhHaIssCo1tX1bpg==; 5:TQFWtp5iC3uYijgEcEV+EcNv4kUMTS3hw4KHZepMo4S4qJvr/xVA5esyOCoENIkwkkQOohjNw2EiPRZGCQn9QSO3k20fv9cF3Rz8+xeX4y+la7ltw1t33QGambGcpPTiW5VY2doow9IetyNpzh7Y7w==; 24:2d5sweDLrQb5MTnhm8KKyCMFfJEdWmxssABk/cI0kiSGPx9Y0B9fNTTpop+MLTwCYWfojGcf3KmuoPJiGNS/3o+Fb+HJHUkDUOp7VLBce8Y=; 7:/r2PfBvvumIh2bikL58ee8vSomivtrDdptjsK5PY0W0IfcG95Cjgxv8z8xhCdH7P+i1CqM2A/6rvKD/677xxhHq6l4XPk4sBrBOyPe2GkOx2LwEl71hs6GnQsT9zB2OX24ypU2RWP2hJbkRBR5ipsS/bAz0XY6zbHpk37GTkf7VGbkLFkQWYRtfgoSuYNkqTKlsrBWg2lPrCxCta0gtsvucVh0QqSDr/GtZ1c6DR17A= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR0401MB2053; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:DB5PR0401MB2053; BCL:0; PCL:0; RULEID:; SRVR:DB5PR0401MB2053; x-forefront-prvs: 0972DEC1D9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(199003)(189002)(13464003)(377454003)(81166006)(81156014)(33656002)(5008740100001)(106356001)(5003600100002)(68736007)(19580405001)(19580395003)(9686002)(3280700002)(66066001)(4326007)(106116001)(50986999)(54356999)(5002640100001)(76176999)(8936002)(5890100001)(2950100001)(122556002)(189998001)(110136002)(5004730100002)(11100500001)(101416001)(87936001)(97736004)(2900100001)(92566002)(77096005)(74316001)(10400500002)(105586002)(3660700001)(2906002)(86362001)(6116002)(102836003)(3846002)(586003)(76576001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR0401MB2053; H:DB5PR0401MB2054.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2016 14:20:05.2474 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR0401MB2053 Subject: Re: [dpdk-dev] [PATCH v1 07/28] 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: Mon, 13 Jun 2016 14:20:07 -0000 Another trivial comment inlined: > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jan Viktorin > Sent: Friday, May 06, 2016 7:18 PM > To: dev@dpdk.org > Cc: Jan Viktorin ; David Marchand > ; Thomas Monjalon ; > Bruce Richardson ; Declan Doherty > ; jianbo.liu@linaro.org; > jerin.jacob@caviumnetworks.com; Keith Wiles ; Step= hen > Hemminger > Subject: [dpdk-dev] [PATCH v1 07/28] eal/soc: add > rte_eal_soc_register/unregister logic >=20 > Signed-off-by: Jan Viktorin > --- > app/test/test_soc.c | 106 > ++++++++++++++++++++++++ > lib/librte_eal/bsdapp/eal/Makefile | 1 + > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + > lib/librte_eal/common/eal_common_soc.c | 55 ++++++++++++ > lib/librte_eal/common/include/rte_soc.h | 23 +++++ > lib/librte_eal/linuxapp/eal/Makefile | 1 + > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 + > 7 files changed, 193 insertions(+) > create mode 100644 lib/librte_eal/common/eal_common_soc.c >=20 > diff --git a/app/test/test_soc.c b/app/test/test_soc.c > index a49fc9b..f6288dc 100644 > --- a/app/test/test_soc.c > +++ b/app/test/test_soc.c > @@ -74,6 +74,103 @@ 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 her= e. > + */ > +struct test_wrapper { > + struct rte_soc_driver soc_drv; > +}; > + > +struct test_wrapper empty_pmd0 =3D { > + .soc_drv =3D { > + .name =3D "empty_pmd0", > + }, > +}; > + > +struct test_wrapper empty_pmd1 =3D { > + .soc_drv =3D { > + .name =3D "empty_pmd1", > + }, > +}; > + > +static int > +count_registered_socdrvs(void) > +{ > + int i; > + struct rte_soc_driver *drv; > + > + i =3D 0; > + TAILQ_FOREACH(drv, &soc_driver_list, next) > + i +=3D 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 =3D TAILQ_FIRST(&soc_driver_list); > + TEST_ASSERT(!strcmp(drv->name, "empty_pmd0"), > + "The registered PMD is not empty_pmd but '%s'", drv->name); Trivial: TEST_ASSERT Message should be: "... is not empty_pmd0 but..." > + > + rte_eal_soc_register(&empty_pmd1.soc_drv); > + > + count =3D count_registered_socdrvs(); > + TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count); > + > + rte_eal_soc_unregister(&empty_pmd0.soc_drv); > + count =3D 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 =3D > + 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 =3D 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 =3D TAILQ_FIRST(&real_soc_driver_list); > + TAILQ_REMOVE(&real_soc_driver_list, drv, next); > + rte_eal_soc_register(drv); > + } > + > return 0; > } >=20 > @@ -83,6 +180,15 @@ test_soc(void) > if (test_compare_addr()) > return -1; >=20 > + if (test_soc_setup()) > + return -1; > + > + if (test_register_unregister()) > + return -1; > + > + if (test_soc_cleanup()) > + return -1; > + > return 0; > } >=20 > diff --git a/lib/librte_eal/bsdapp/eal/Makefile > b/lib/librte_eal/bsdapp/eal/Makefile > index 9054ad6..d956808 100644 > --- a/lib/librte_eal/bsdapp/eal/Makefile > +++ b/lib/librte_eal/bsdapp/eal/Makefile > @@ -71,6 +71,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_time= r.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_memzone.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_log.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_launch.c > +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_soc.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_pci.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_pci_uio.c > SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) +=3D eal_common_memory.c > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > index 4d075df..c430b4b 100644 > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > @@ -158,4 +158,7 @@ DPDK_16.07 { > rte_eal_dev_attach; > rte_eal_dev_detach; >=20 > + rte_eal_soc_register; > + rte_eal_soc_unregister; > + > } DPDK_16.04; > 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..afeed2f > --- /dev/null > +++ b/lib/librte_eal/common/eal_common_soc.c > @@ -0,0 +1,55 @@ > +/*- > + * 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 copyrig= ht > + * 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 F= OR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGH= T > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTA= L, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF US= E, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A= NY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE U= SE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE= . > + */ > + > +#include > + > +#include > + > +#include "eal_private.h" > + > +struct soc_driver_list soc_driver_list =3D > + 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 cde588a..28c1798 100644 > --- a/lib/librte_eal/common/include/rte_soc.h > +++ b/lib/librte_eal/common/include/rte_soc.h > @@ -46,11 +46,17 @@ extern "C" { >=20 > #include > #include > +#include > #include > #include > #include >=20 > #include > +#include > + > +TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linke= d Q. > */ > + > +extern struct soc_driver_list soc_driver_list; /**< Global list of SoC > drivers. */ >=20 > struct rte_soc_id { > const char *compatible; /**< OF compatible specification */ > @@ -131,4 +137,21 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *= a0, > return strcmp(a0->name, a1->name); > } >=20 > +/** > + * Register a SoC driver. > + */ > +void rte_eal_soc_register(struct rte_soc_driver *driver); > + > +#define RTE_EAL_SOC_REGISTER(name) \ > +RTE_INIT(socinitfn_ ##name); \ > +static void socinitfn_ ##name(void) \ > +{ \ > + rte_eal_soc_register(&name.soc_drv); \ > +} > + > +/** > + * 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 e109361..37ab8d5 100644 > --- a/lib/librte_eal/linuxapp/eal/Makefile > +++ b/lib/librte_eal/linuxapp/eal/Makefile > @@ -82,6 +82,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_ti= mer.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_memzone.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_log.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_launch.c > +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_soc.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_pci.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_pci_uio.c > SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) +=3D eal_common_memory.c > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > index 0404a52..6ff38b8 100644 > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > @@ -161,4 +161,8 @@ DPDK_16.07 { > rte_eal_dev_attach; > rte_eal_dev_detach; >=20 > + soc_driver_list; > + rte_eal_soc_register; > + rte_eal_soc_unregister; > + > } DPDK_16.04; > -- > 2.8.0