From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00065.outbound.protection.outlook.com [40.107.0.65]) by dpdk.org (Postfix) with ESMTP id 70002590B for ; Fri, 16 Sep 2016 08:18:28 +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=2ZV1OdprlNwHVryDOfSlypdel3sQHZO6mOSNRO9tspI=; b=pfDNd4LWklV39ncu5HYWl2iityIkNOZbRrJEFWIyj6/MpHMTQ4l+1AxaZz5cqhNC00WqkZ9xjw9NqY3OnEcCh7YxGJl9wPutxdOsT1cmktb11WYsxTsNleWU8EtItcvtAnTylz37stD66pXe4hG+6dmQTZ8Gp2gJMhckO8lrW2I= Received: from DB5PR0401MB2054.eurprd04.prod.outlook.com (10.166.11.137) by DB5PR04MB1608.eurprd04.prod.outlook.com (10.164.38.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.6; Fri, 16 Sep 2016 06:18:26 +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.0639.002; Fri, 16 Sep 2016 06:18:27 +0000 From: Shreyansh Jain To: "Hunt, David" , "dev@dpdk.org" CC: "viktorin@rehivetech.com" , Hemant Agrawal Thread-Topic: [dpdk-dev] [PATCH v3 01/15] eal/soc: introduce very essential SoC infra definitions Thread-Index: AQHSCnZ37aX3R2L2MUCJn352RzQh0KB6jN6AgAEhGhA= Date: Fri, 16 Sep 2016 06:17:59 +0000 Deferred-Delivery: Fri, 16 Sep 2016 06:17:30 +0000 Message-ID: References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> <1473410639-10367-2-git-send-email-shreyansh.jain@nxp.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: 9cae0b47-eee0-4aa6-5003-08d3ddf94570 x-microsoft-exchange-diagnostics: 1; DB5PR04MB1608; 6:fIO1OZa7++l0jKWkNlrebK8mHWqVWIKaOsm9mLWee632cEdfm87dNZj55x6/peZZkWUq3QpNE8Ms4I+vce72yB6Ml8fnMuwqFGV0VIpXGJL4mo5W/8lYlphs0V44vcz8DxO8CLcFt925bnmT4H+q2nQSK2gxla4n2DyelXyfZbMoTxAsI/+9JWnzKqAYnHl+8dqzA+R1YFIIUw1iXFfQx3a5nqM5CzKBFWo9HwqH9PFpMh+l5xi2CLv3X271AG9Jt7o27YCaWFsfC0cjOxwKn1u0QBBBPUkwBgFDH1wF6K4PO0LI8oVOcFV3o+SweIgl1SsrPfUOC0PgT8lgWtyVEw==; 5:/tPpvyHNmxsktuBVmcX44n/zT2qV8WXePlJnUmEtYe31gstzoB7QVcn5JhjHaMEA4UJ2l/NtJwJtouw0JsnMfWUbg3LJgY4I7vAUyxeaHajfLx6HKI0nGE+isIRaTmmRiJvEMnWyit9UIOGDXp0xgw==; 24:c6W9Hv7d6jNKOJra4buYybzzyqnkAsfQ+67V5IK/hNN+VpREKTBsckx4DV7OIyX+mSE4nGfkadXhoFcLHBCvbtAvEAXhtBAsCD9NEp9XiMw=; 7:55I2MTJRwT7lXDOgmf5ybOKrxEEGOkHFv3V+iRx6UvmlAB9XPfFomfiZVvjuAoJu3xtyQ2KDR0El7/L3ga3AkPZ5w9sonO4WIECrm4tkHZ2PyKwuYnJhgIm3Ya853XNnxs93Bz+AW7wxU/jkqjXku3A5EkTBn9580aL5YKpqOvJnfKKIXkh0pWE3v1dmCrBoz/oc0VQNAZ2SGbwNkmeGjzjYJsX16GFlt/Hpe++VG5diFp1FRV3w1dGRwSQQhYLd x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB1608; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DB5PR04MB1608; BCL:0; PCL:0; RULEID:; SRVR:DB5PR04MB1608; x-forefront-prvs: 0067A8BA2A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(13464003)(24454002)(189002)(199003)(377454003)(66066001)(77096005)(5660300001)(5001770100001)(2906002)(97736004)(2900100001)(8676002)(81156014)(122556002)(5002640100001)(8936002)(3846002)(93886004)(19580395003)(6116002)(92566002)(87936001)(19580405001)(2950100001)(86362001)(586003)(7846002)(189998001)(575784001)(102836003)(2501003)(54356999)(9686002)(4326007)(3280700002)(106116001)(33656002)(68736007)(10400500002)(50986999)(106356001)(76176999)(105586002)(101416001)(7696004)(81166006)(305945005)(7736002)(74316002)(76576001)(3660700001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1608; H:DB5PR0401MB2054.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; 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: 16 Sep 2016 06:18:26.9884 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1608 Subject: Re: [dpdk-dev] [PATCH v3 01/15] eal/soc: introduce very essential SoC infra definitions 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, 16 Sep 2016 06:18:28 -0000 Hi David, > -----Original Message----- > From: Hunt, David [mailto:david.hunt@intel.com] > Sent: Thursday, September 15, 2016 6:29 PM > To: Shreyansh Jain ; dev@dpdk.org > Cc: viktorin@rehivetech.com; Hemant Agrawal > Subject: Re: [dpdk-dev] [PATCH v3 01/15] eal/soc: introduce very essentia= l > SoC infra definitions >=20 > Some small comments below: >=20 > On 9/9/2016 9:43 AM, Shreyansh Jain wrote: > > Define initial structures and functions for the SoC infrastructure. > > This patch supports only a very minimal functions for now. > > More features will be added in the following commits. > > > > Includes rte_device/rte_driver inheritance of > > rte_soc_device/rte_soc_driver. > > > > Signed-off-by: Jan Viktorin > > Signed-off-by: Shreyansh Jain > > Signed-off-by: Hemant Agrawal > > --- > > app/test/Makefile | 1 + > > app/test/test_soc.c | 90 +++++++++++++++++++++ > > lib/librte_eal/common/Makefile | 2 +- > > lib/librte_eal/common/eal_private.h | 4 + > > lib/librte_eal/common/include/rte_soc.h | 138 > ++++++++++++++++++++++++++++++++ > > 5 files changed, 234 insertions(+), 1 deletion(-) > > create mode 100644 app/test/test_soc.c > > create mode 100644 lib/librte_eal/common/include/rte_soc.h > > > > diff --git a/app/test/Makefile b/app/test/Makefile > > index 611d77a..64b261d 100644 > > --- a/app/test/Makefile > > +++ b/app/test/Makefile > > @@ -77,6 +77,7 @@ APP =3D test > > # > > SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) :=3D commands.c > > SRCS-y +=3D test.c > > +SRCS-y +=3D test_soc.c > > SRCS-y +=3D resource.c > > SRCS-y +=3D test_resource.c > > test_resource.res: test_resource.c > > diff --git a/app/test/test_soc.c b/app/test/test_soc.c > > new file mode 100644 > > index 0000000..916a863 > > --- /dev/null > > +++ b/app/test/test_soc.c > > @@ -0,0 +1,90 @@ > > +/*- > > + * BSD LICENSE > > + * > > + * Copyright(c) 2016 RehiveTech. All rights reserved. > > + * All rights reserved. >=20 > Remove un-needed "All rights reserved" =20 I think duplicated messages doesn't make sense. I can remove them. But, I w= ould like to wait a while based on the mails from Jan and Thomas - in case = this is expected. As far as I know, only a single 'All rights reserved' is required - probabl= y the lower one got left out in some very early license copy operations and= continued unnoticed. (git blame? :D) >=20 > > + * > > + * 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 > > +#include > > + > > +#include > > +#include > > +#include > > + > > +#include "test.h" > > + > > +static char *safe_strdup(const char *s) > > +{ > > + char *c =3D strdup(s); > > + > > + if (c =3D=3D NULL) > > + rte_panic("failed to strdup '%s'\n", s); > > + > > + return c; > > +} > > + > > +static int test_compare_addr(void) > > +{ > > + struct rte_soc_addr a0; > > + struct rte_soc_addr a1; > > + struct rte_soc_addr a2; > > + > > + a0.name =3D safe_strdup("ethernet0"); > > + a0.fdt_path =3D NULL; > > + > > + a1.name =3D safe_strdup("ethernet0"); > > + a1.fdt_path =3D NULL; > > + > > + a2.name =3D safe_strdup("ethernet1"); > > + a2.fdt_path =3D NULL; > > + > > + TEST_ASSERT(!rte_eal_compare_soc_addr(&a0, &a1), > > + "Failed to compare two soc addresses that equal"); > > + TEST_ASSERT(rte_eal_compare_soc_addr(&a0, &a2), > > + "Failed to compare two soc addresses that differs"); > > + > > + free(a2.name); > > + free(a1.name); > > + free(a0.name); > > + return 0; > > +} > > + > > +static int > > +test_soc(void) > > +{ > > + if (test_compare_addr()) > > + return -1; > > + > > + return 0; > > +} > > + > > +REGISTER_TEST_COMMAND(soc_autotest, test_soc); > > diff --git a/lib/librte_eal/common/Makefile > b/lib/librte_eal/common/Makefile > > index dfd64aa..b414008 100644 > > --- a/lib/librte_eal/common/Makefile > > +++ b/lib/librte_eal/common/Makefile > > @@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk > > > > INC :=3D rte_branch_prediction.h rte_common.h > > INC +=3D rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h > > -INC +=3D rte_log.h rte_memory.h rte_memzone.h rte_pci.h > > +INC +=3D rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h > > INC +=3D rte_per_lcore.h rte_random.h > > INC +=3D rte_tailq.h rte_interrupts.h rte_alarm.h > > INC +=3D rte_string_fns.h rte_version.h > > diff --git a/lib/librte_eal/common/eal_private.h > b/lib/librte_eal/common/eal_private.h > > index 431d6c2..df6582d 100644 > > --- a/lib/librte_eal/common/eal_private.h > > +++ b/lib/librte_eal/common/eal_private.h > > @@ -36,6 +36,7 @@ > > > > #include > > #include > > +#include > > > > /** > > * Initialize the memzone subsystem (private to eal). > > @@ -126,6 +127,9 @@ int rte_eal_log_init(const char *id, int facility); > > */ > > int rte_eal_pci_init(void); > > > > +struct rte_soc_driver; > > +struct rte_soc_device; > > + > > struct rte_pci_driver; > > struct rte_pci_device; > > > > diff --git a/lib/librte_eal/common/include/rte_soc.h > b/lib/librte_eal/common/include/rte_soc.h > > new file mode 100644 > > index 0000000..bc0a43b > > --- /dev/null > > +++ b/lib/librte_eal/common/include/rte_soc.h > > @@ -0,0 +1,138 @@ > > +/*- > > + * BSD LICENSE > > + * > > + * Copyright(c) 2016 RehiveTech. All rights reserved. > > + * All rights reserved. >=20 > Remove un-needed "All rights reserved" Same as above. I prefer to remove but I'll wait a while in case someone has= anything else to add to this. >=20 > > + * > > + * 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. > > + */ > > + > > +#ifndef _RTE_SOC_H_ > > +#define _RTE_SOC_H_ > > + > > +/** > > + * @file > > + * > > + * RTE SoC Interface > > + */ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +struct rte_soc_id { > > + const char *compatible; /**< OF compatible specification */ > > + uint64_t priv_data; /**< SoC Driver specific data */ > > +}; > > + > > +struct rte_soc_addr { > > + char *name; /**< name used in sysfs */ > > + char *fdt_path; /**< path to the associated node in FDT */ > > +}; > > + > > +/** > > + * A structure describing a SoC device. > > + */ > > +struct rte_soc_device { > > + TAILQ_ENTRY(rte_soc_device) next; /**< Next probed SoC device */ > > + struct rte_device device; /**< Inherit code device */ > > + struct rte_soc_addr addr; /**< SoC device Location */ > > + struct rte_soc_id *id; /**< SoC device ID list */ > > + struct rte_soc_driver *driver; /**< Associated driver */ > > +}; > > + > > +struct rte_soc_driver; > > + > > +/** > > + * Initialization function for the driver called during SoC probing. > > + */ > > +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_de= vice > *); > > + > > +/** > > + * Uninitialization function for the driver called during hotplugging. > > + */ > > +typedef int (soc_devuninit_t)(struct rte_soc_device *); > > + > > +/** > > + * A structure describing a SoC driver. > > + */ > > +struct rte_soc_driver { > > + TAILQ_ENTRY(rte_soc_driver) next; /**< Next in list */ > > + struct rte_driver driver; /**< Inherit core driver. */ > > + soc_devinit_t *devinit; /**< Device initialization */ > > + soc_devuninit_t *devuninit; /**< Device uninitialization */ > > + const struct rte_soc_id *id_table; /**< ID table, NULL terminated */ > > +}; > > + > > +/** > > + * Utility function to write a SoC device name, this device name can l= ater > be > > + * used to retrieve the corresponding rte_soc_addr using above functio= ns. > > + * > > + * @param addr > > + * The SoC address > > + * @param output > > + * The output buffer string > > + * @param size > > + * The output buffer size > > + * @return > > + * 0 on success, negative on error. > > + */ > > +static inline void > > +rte_eal_soc_device_name(const struct rte_soc_addr *addr, > > + char *output, size_t size) > > +{ > > + int ret; > > + > > + RTE_VERIFY(addr !=3D NULL); > > + RTE_VERIFY(size >=3D strlen(addr->name)); > > + ret =3D snprintf(output, size, "%s", addr->name); > > + RTE_VERIFY(ret >=3D 0); > > +} > > + > > +static inline int > > +rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, > > + const struct rte_soc_addr *a1) > > +{ > > + if (a0 =3D=3D NULL || a1 =3D=3D NULL) > > + return -1; > > + > > + RTE_VERIFY(a0->name !=3D NULL); > > + RTE_VERIFY(a1->name !=3D NULL); > > + > > + return strcmp(a0->name, a1->name); > > +} > > + > > +#endif - Shreyansh