From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0078.outbound.protection.outlook.com [104.47.37.78]) by dpdk.org (Postfix) with ESMTP id B694DBB0C for ; Thu, 27 Oct 2016 17:17:38 +0200 (CEST) Received: from DM2PR03CA0002.namprd03.prod.outlook.com (10.141.96.12) by CY1PR03MB2378.namprd03.prod.outlook.com (10.166.207.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Thu, 27 Oct 2016 15:17:37 +0000 Received: from BL2FFO11FD030.protection.gbl (2a01:111:f400:7c09::126) by DM2PR03CA0002.outlook.office365.com (2a01:111:e400:2428::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12 via Frontend Transport; Thu, 27 Oct 2016 15:17:37 +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 BL2FFO11FD030.mail.protection.outlook.com (10.173.161.40) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Thu, 27 Oct 2016 15:17:36 +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 u9RFGIfa027183; Thu, 27 Oct 2016 08:17:34 -0700 From: Shreyansh Jain To: Date: Thu, 27 Oct 2016 20:47:32 +0530 Message-ID: <1477581467-12588-7-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> References: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131220550569419252; (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)(199003)(189002)(76176999)(36756003)(2950100002)(97736004)(356003)(77096005)(50986999)(104016004)(189998001)(6916009)(92566002)(5003940100001)(7846002)(87936001)(2906002)(305945005)(47776003)(8666005)(85426001)(586003)(4326007)(2351001)(105606002)(106466001)(229853001)(86362001)(33646002)(8676002)(48376002)(8936002)(19580405001)(68736007)(19580395003)(50226002)(110136003)(81166006)(11100500001)(81156014)(5660300001)(50466002)(626004)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2378; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD030; 1:3nXqN2GZepnOvEYNmcuZvtpze+4t9PUnn8reVamnY8Zg3mncT4D2G+KEvfNF9EONOEAwAh0oNPbSqqvrCYbaM8FKmyEIgJk9LntT+kZGNE3tTx25zwf0VnDsbKTQytzztxQmdSzvkOLh2QEEtdaIDFtrYYvfmm7ws8T6sjt1Cyss4RbatQwiILF+kHDFoAggUvvPmre+mcdJkzLhlyaeGVgvHEjBgdST0FtfuPov1H3DMehUjRJ/px6EV4eqtnBaHRY9FKsW0e33JtX9wpXgSp8a5S1enIqQp+twVhYovj0ppXZxlmlJcteSziHEtladeFltpwRY0zNiSdawfxTg/dudIZe/XPKRYclckIDclT3XG7CrNmOzsbmqNsnIFFwpidIXWd2LnmpHgmEyDyNT6dXcd6MwB/seQDlY6n5kmqu46i/3qv+AwC6xjX+RMrimo+CAeEtCnV3kwmOt7M14088KiyLNsGnYw+wR9rdMM5LUG+qjPdaYc8IaODTI/I4JYtd6/h+QKVGLBpGc6veeU0mmtFQ01APXViCh8AuWMSOqbo5WthRYXte7eDj/RlOL5UqVLuJwoBAaM3PV5CADVQoO5c2JtSpWudr2LVMT73Vzt3jhk5S1ssrz+/OVX/L5BI4mOMdEWZj9YbCNUzwA5VTazk0j6FVFuz1dwmd+C8n66vlthU8BbFp6UoRLPOVgIYnZNToamO0FgJ3obndiOxJuAgvHuS17kB25Twv4K8M= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ddfab296-ac17-4ad0-e1f4-08d3fe7c6262 X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2378; 2:03Sf/LV2DuEnuwgx+u0+E9DnVB1ZdVX33GxyGSEXmumpeYAiQR7ixfyEi3od45yXaWKJWKXGQpVVySXJVT0EHaWE88bFPGVHCW8n9O7ZBstUlfjq/9X1teGKE9IJbp8w+e6Q2pHJQArGE7+lsuVsApTdqzgvXbOKYnpUpIRqHieXPYEhAv9yU6z/dxVH4XXd4HmxrCCfmmDq60eDHQkCFA==; 3:pZWR4QrgMs0i/msZrjmET9PZm6ZWQeUtS2pl3y/ZmEube+tLX04JG8ee3sc0eM3bg4EoXBx7RYdtDD2iVDqhR9rXrda19vHk4S8ymTmme57jjMh5YEXv9htwJc1LTM1rzuvDi3LLzVMiBHdvraQNvSV1rfrv24EEfrbBPKB1aF2IwGkT54nn9Z/fb7HfB0/MkOWVMImkqZkkvV8ImCTRJlO99Z83SID62jx4h5Xl2dBUedj/Iz5QXZzjNQ5mAFmD X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB2378; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2378; 25:u3py6Y+l/r6OF3RA6EhHJc/EntrTHQrzq18xi8svKiVpvk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cGHjoSjezZsdLE5WQ8=; 4:4imK6FrDQ7BkL9vfjSPm1xY2sSLiDxz+PMEJJwInqwZ1q5L54Z/kc0oCMivPcADEVbpo7x3lgJ8SqkVS8zB8u5S+5jLzIDzqWy1tWrzqvfEGTJEkTKXIlVB8KpPaY3V+vkVt3ArM1/XSWeh4r05yTL2oCzxkLTJD3MY6wOwqiFQMAtibjTJWVA/oY9Q6r3hQWFmxjim63Z4p+hsOZ/haZ5UAt+oX/N8Ip2XZPDldk8qY7lRXlGRcXp7n6I1toOWqeaAV7KWVyLSvjZHv0wMF8v7na09pXaIyJ7+WaFjcffgMuyO9BT/L0eHh+bViv30viJJqCf6+ce0LLjGsN1XNA0Ar8dt5LKuTUTSj73lpblUeZyfopHICbFO6LkpjPx/dJn3f+yhpwB0Sr5tFPkIo6A9eZaP2edceXm7GmEQV+CNatuT+SR1Lohhjy6ukUbLbxduuT/x114bd8XoXh5Jj7e4jg0jyImPxPqoW0ZhP5Dbxv7fNCEMoSmsXxor5tltHBEQ39GktjZ3N9rWw63wZdytMPrIejjfJWbRS2646snYq+6zZnuDJU22NR0UWP9G7 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)(13023025)(13024025)(5005006)(13018025)(13017025)(13015025)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR03MB2378; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2378; X-Forefront-PRVS: 0108A997B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2378; 23:ih9jJRYEeU2lp7twmP1IHlJSN9NfaKT1vw89mrVJI?= =?us-ascii?Q?vwYmTRKBGs/gJPHzvrzZ1X7f8U+YtbnJ38V+6VSWoNfhwduFbDzOMt1UbRIR?= =?us-ascii?Q?rbr4po5505FGTqaIVuX6LCziPlBeccqBkuw1WccaL+xSLBgRLZj6Icx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Z8G76Tkh32N9XLUwpoGjk0iHNAZ0WtL+k3w055xQCfI+NP?= =?us-ascii?Q?DIhzSUJawReAiaabcF69g0LeouJWu3OoKl6k19gBLxiXjoNMptzKxYJVFb1W?= =?us-ascii?Q?CF0Fg8BWESNePIvOZ4NUnD8k9gCwVbp00mZyKQxOdsKtLkpurhfJaRrTdSby?= =?us-ascii?Q?dIO5w3T0/rekRc=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2378; 6:MvuOo9hZwCCJT1HP4GPjWAiWVHDawLBN87Mt0HaoICPCaC7F9ktwOHijwGoNNYOKESHzLMAyKeJAuMIA16IPwyNw+Rcotv2Sr7DTHgDIUkU4+bGJSnu/cG0dSWexFd0DDZr2ArkIrAlozuzug2WK7BmFBTIZmmAkUC/8m1Yf+THCIofjh+1ZXHkqk+9KSKGbFM78jDpdyuyQyeleYJvXm+Ccecbeom1cLRZjJBvwRPGOlYpAvowXLSYUVD3JiZBA9uUn6t5XclvOcMeS9EJckLcndz3/GjAcTLdrN7gzLYR6mvkwWxsS3CS2d/lkiq72; 5:+uDneHcV6mR5G2mqY6e9HqZxQofcfkpLKpY7gpySV8cwySrwh8AYfVUyH4v9VLX7+4NlmKpyyvws4x20bNqb7Lk8jzZqRjlcR8WAa+NOBKQt9WzfgNYxyw8XLvP4raAmELCyY9pj5pTCd5Ol6qSiuwytHIIFmsQftVGFn8OSKLs/YKXnylXyu6xJ3MEF4taP; 24:lzyHzKuGNFUjmu85lWNb/Z+eaxCCtZXb108xikYCcJE/6eE/SCVMbKL7xe0kSFFYG5cU1GQCeKW7AClSPRQXPgmDcSeSNyDexum1BQ/Up2U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2378; 7:JMoZVeua2Mk2Z7lWzn0M88Ub7UDkJlATW87vgznSzKV4OqFtu3Av4vux/wYpjteEhTB5UcjlHMXPITlF6xX5HniKhrJ3NLKfdWXiHpGbausO9l4Xobpw+5eiOzdAsGg5ECrxlxR084u/DQlZVknDSCATsIkMRBJjZcfG26a6Nhmi0xNeRnbIKrHHDI80nSmkap6iDKmYDjz3IOZ0BUNMD4WpZ1VajcnMTiTWmjeILNSgIU8cjnrtKnKRYsSM+SSinjl7wYGtOugw6rV3HZsfqU0u0FitYOGbHxUc4uaRlup6gXoovaM/4zEjIZuyZtWLh1T2EFFSTi/TVan8CNLKBizNIwNMzX26FFli9nldgrw= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 15:17:36.7547 (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: CY1PR03MB2378 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v6 06/21] 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, 27 Oct 2016 15:17:39 -0000 From: Jan Viktorin 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 5be023a..30295af 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. + * + * 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 c8c2131..0e8d6f7 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). @@ -118,6 +119,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..5c32737 --- /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. + * + * 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; + +/** + * Probe function for the driver called during SoC probing. + */ +typedef int (soc_probe_t)(struct rte_soc_driver *, struct rte_soc_device *); + +/** + * Remove function for the driver called during hotplugging. + */ +typedef int (soc_remove_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_probe_t *probe; /**< Device probe */ + soc_remove_t *remove; /**< Device remove */ + 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 -- 2.7.4