From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0076.outbound.protection.outlook.com [104.47.0.76]) by dpdk.org (Postfix) with ESMTP id 73852ADD0 for ; Wed, 15 Jun 2016 07:57:46 +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=dvLe+FUSdKMkyGwCBgoaPIThogVwWhxsYABu+oh+sLM=; b=goTWiJTVJcdqXlkFtrkUIKJL4ruyKK5ttbnaqlmoxEZWFuQxWlHIzpS522KV9gaxWSC3vy0gyGzpyHGBhBo8rOjz39w2uREwcWxeOhBn44l5whzS25jdIFqaFqNdDPrICY19NaEzTS0CiOKXLStgSWGa0tPXCQR0PX7L/ln5imE= Received: from DB5PR0401MB2054.eurprd04.prod.outlook.com (10.166.11.137) by DB5PR0401MB2055.eurprd04.prod.outlook.com (10.166.11.138) with Microsoft SMTP Server (TLS) id 15.1.517.8; Wed, 15 Jun 2016 05:57:44 +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.013; Wed, 15 Jun 2016 05:57:44 +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: AQHRxsrPCxbiXA90DkWhszKtUpKUHQ== Date: Wed, 15 Jun 2016 05:57:33 +0000 Deferred-Delivery: Wed, 15 Jun 2016 05:56:43 +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: 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: 0256a8f9-e221-4ffb-ea82-08d394e1f88c x-microsoft-exchange-diagnostics: 1; DB5PR0401MB2055; 6:74kyi+fjuPzBUOtZK2DAyNWezKKY2XvIxBzz2R0QHOaquYpLOe4PZOkpCLjb4hvVfrsnuvCV3mIKttDKvp/OXO3lL82nTiDMEqgDaJEFi62hMKL04yau0eAA3TZHCeT8BmP5UgOpr9S5PmpMMIjCdFMjZKB4Hi9VmatRBl3nY/R/QljAwDKUDwy4FgvNZw91CydheS1op2UPn9bI/heE/LKcgS1/yRfWAS8LFpp2ejXfbvhBy3v1jaq4HeSSHu3OXdX+v47NlZlbQ9qvZ8+AFJB9SViCs0CamhJVyL0mREbQDCScQ4yGQj5XQKkZuog1; 5:CYm7fBkC08D2XDh0DWa1m0bjtRTjX2klsx3w00+T89SIxx9hhDDKROCk2e4W6hDW4E14nG1Oly5IipDkHoLDB3Uk41OGSmudPKeJIlQUpFO6rJ49PipwqJBTwr9qwGMS822u/T3AqA8khq/6OFRa7A==; 24:/8yBUiTogvc3pPszrVjgaU+Mn2Eu2vIy+3TaJkLHQYJeqZfh0kM9FfizC5poVXG7kRTKdQfUedR6bQriI3b0BDnIG8ZtTPh+U3BII1AbhlQ=; 7:kfF0hyyfS28LJealPbnfSqMF5Mg2THQKqeCBj03KUriUdMxexuRpEuEWp6Vj+3nAR/77TSzwy/WrBnUT0BYZaa5jE6PC5qbp1qFbHihnnF6aiHHC4JSkx40Mr0D4R5n9qbCqoUD+VkKgf7ylSOtSMhcM+8RsUPguMJ+QHbmaiDL3gjnal7P3R9gZMZDSAcFpEFe+H9N48GNQEcx97A/2fw== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR0401MB2055; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:DB5PR0401MB2055; BCL:0; PCL:0; RULEID:; SRVR:DB5PR0401MB2055; x-forefront-prvs: 09749A275C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(199003)(189002)(13464003)(377454003)(5004730100002)(86362001)(5008740100001)(68736007)(76576001)(101416001)(92566002)(3280700002)(9686002)(33656002)(77096005)(6116002)(102836003)(3846002)(3660700001)(2900100001)(2950100001)(105586002)(586003)(122556002)(81166006)(81156014)(4326007)(74316001)(5003600100002)(2906002)(50986999)(10400500002)(106356001)(106116001)(54356999)(87936001)(76176999)(5890100001)(97736004)(110136002)(11100500001)(189998001)(5002640100001)(19580405001)(8936002)(19580395003)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR0401MB2055; 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: 15 Jun 2016 05:57:44.5626 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR0401MB2055 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: Wed, 15 Jun 2016 05:57:46 -0000 Hi Jan, One more comment which I missed in previous reply: > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shreyansh Jain > Sent: Monday, June 13, 2016 7:50 PM > To: Jan Viktorin > Cc: David Marchand ; Thomas Monjalon > ; Bruce Richardson ; > Declan Doherty ; jianbo.liu@linaro.org; > jerin.jacob@caviumnetworks.com; Keith Wiles ; Step= hen > Hemminger ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v1 07/28] eal/soc: add > rte_eal_soc_register/unregister logic >=20 > Another trivial comment inlined: >=20 > > -----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 ; > Stephen > > Hemminger > > Subject: [dpdk-dev] [PATCH v1 07/28] eal/soc: add > > rte_eal_soc_register/unregister logic > > > > 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 > > > > 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 h= ere. > > + */ > > +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); >=20 > Trivial: TEST_ASSERT Message should be: "... is not empty_pmd0 but..." >=20 > > + > > + 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; > > } > > > > @@ -83,6 +180,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/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_ti= mer.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; > > > > + 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 withou= t > > + * modification, are permitted provided that the following condition= s > > + * are met: > > + * > > + * * Redistributions of source code must retain the above copyrigh= t > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyr= ight > > + * 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 deriv= ed > > + * from this software without specific prior written permission. > > + * > > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTO= RS > > + * "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 COPYRI= GHT > > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDEN= TAL, > > + * 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 TO= RT > > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE= USE > > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. > > + */ > > + > > +#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" { > > > > #include > > #include > > +#include > > #include > > #include > > #include > > > > #include > > +#include > > + > > +TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-lin= ked > Q. > > */ > > + > > +extern struct soc_driver_list soc_driver_list; /**< Global list of SoC > > drivers. */ > > > > 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); > > } > > > > +/** > > + * 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); \ It should be 'rte_eal_soc_register(&name)'. As a user of 'RTE_EAL_SOC_REGISTER', I would pass reference to 'rte_soc_dri= ver' object. It doesn't have any 'soc_drv' member. I am guessing that because you have created a wrapper structure 'test_wrapp= er' in test_soc.c which contains a 'soc_drv', the macro reflects that usage= . > > +} > > + > > +/** > > + * 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_timer.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; > > > > + soc_driver_list; > > + rte_eal_soc_register; > > + rte_eal_soc_unregister; > > + > > } DPDK_16.04; > > -- > > 2.8.0 - Shreyansh