From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id BF5D75594 for ; Thu, 15 Sep 2016 14:58:50 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 15 Sep 2016 05:58:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,339,1470726000"; d="scan'208";a="1040361441" Received: from dhunt5-mobl.ger.corp.intel.com (HELO [10.237.220.115]) ([10.237.220.115]) by fmsmga001.fm.intel.com with ESMTP; 15 Sep 2016 05:58:48 -0700 To: Shreyansh Jain , dev@dpdk.org 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> Cc: viktorin@rehivetech.com, hemant.agrawal@nxp.com From: "Hunt, David" Message-ID: Date: Thu, 15 Sep 2016 13:58:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1473410639-10367-2-git-send-email-shreyansh.jain@nxp.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: Thu, 15 Sep 2016 12:58:51 -0000 Some small comments below: 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 = test > # > SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c > SRCS-y += test.c > +SRCS-y += test_soc.c > SRCS-y += resource.c > SRCS-y += 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. Remove un-needed "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 > +#include > + > +#include > +#include > +#include > + > +#include "test.h" > + > +static char *safe_strdup(const char *s) > +{ > + char *c = strdup(s); > + > + if (c == 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 = safe_strdup("ethernet0"); > + a0.fdt_path = NULL; > + > + a1.name = safe_strdup("ethernet0"); > + a1.fdt_path = NULL; > + > + a2.name = safe_strdup("ethernet1"); > + a2.fdt_path = 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 := rte_branch_prediction.h rte_common.h > INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h > -INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h > +INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h > INC += rte_per_lcore.h rte_random.h > INC += rte_tailq.h rte_interrupts.h rte_alarm.h > INC += 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. Remove un-needed "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. > + */ > + > +#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_device *); > + > +/** > + * 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 later be > + * used to retrieve the corresponding rte_soc_addr using above functions. > + * > + * @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 != NULL); > + RTE_VERIFY(size >= strlen(addr->name)); > + ret = snprintf(output, size, "%s", addr->name); > + RTE_VERIFY(ret >= 0); > +} > + > +static inline int > +rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, > + const struct rte_soc_addr *a1) > +{ > + if (a0 == NULL || a1 == NULL) > + return -1; > + > + RTE_VERIFY(a0->name != NULL); > + RTE_VERIFY(a1->name != NULL); > + > + return strcmp(a0->name, a1->name); > +} > + > +#endif