From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D144A0487 for ; Mon, 1 Jul 2019 09:16:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E0670271; Mon, 1 Jul 2019 09:16:42 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00045.outbound.protection.outlook.com [40.107.0.45]) by dpdk.org (Postfix) with ESMTP id 4E8151D7 for ; Mon, 1 Jul 2019 09:16:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SURvMSvuOXjXRvEhrfuATP8FdLk7Qwq74lRMd7sjAUo=; b=b9Bfd6HxopHflhf+g5D+QWOKC0wVVPTMUH0LpSoYalKtfWftCHjasyPo1zNHBQs51yx/eJCi0pRkPmU4VjOuNod2nJP9ZZJ6RJ8iziMuu1Ik6kSkHPj3JTMzhic6AECJEPd5D/X61M00aiEG6CoSQzlVfLLBNGxqfnovw9YhR2g= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB3199.eurprd08.prod.outlook.com (52.133.15.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.18; Mon, 1 Jul 2019 07:16:39 +0000 Received: from VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::f1a9:e870:d495:8d31]) by VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::f1a9:e870:d495:8d31%5]) with mapi id 15.20.2032.019; Mon, 1 Jul 2019 07:16:39 +0000 From: "Gavin Hu (Arm Technology China)" To: Stephen Hemminger CC: "dev@dpdk.org" , "thomas@monjalon.net" , "jerinj@marvell.com" , "hemant.agrawal@nxp.com" , "bruce.richardson@intel.com" , "chaozhu@linux.vnet.ibm.com" , Honnappa Nagarahalli , nd , "gaetan.rivet@6wind.com" , "Gavin Hu (Arm Technology China)" Thread-Topic: [dpdk-dev] [RFC 1/5] eal: add the APIs to wait until equal Thread-Index: AQHVL1/p6I9OLSsAOECZ0PPDfKo2XKa0pdaAgACwxmA= Date: Mon, 1 Jul 2019 07:16:39 +0000 Message-ID: References: <1561911676-37718-1-git-send-email-gavin.hu@arm.com> <1561911676-37718-2-git-send-email-gavin.hu@arm.com> <20190630132753.3f8139f0@hermes.lan> In-Reply-To: <20190630132753.3f8139f0@hermes.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 7ba8c1b1-788d-4a44-ab97-70c0f734c504.0 x-checkrecipientchecked: true authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b5d2ab9c-1ee5-44bd-ea58-08d6fdf40fb8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR08MB3199; x-ms-traffictypediagnostic: VI1PR08MB3199: x-ms-exchange-purlcount: 1 x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-microsoft-antispam-prvs: nodisclaimer: True x-ms-oob-tlc-oobclassifiers: OLM:419; x-forefront-prvs: 00851CA28B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(136003)(39850400004)(346002)(396003)(366004)(13464003)(189003)(199004)(8676002)(486006)(81156014)(8936002)(81166006)(6506007)(53546011)(55236004)(186003)(74316002)(2906002)(446003)(102836004)(478600001)(52536014)(11346002)(73956011)(64756008)(66446008)(76116006)(33656002)(66946007)(66066001)(66556008)(476003)(66476007)(14454004)(26005)(25786009)(9686003)(6306002)(53936002)(76176011)(6436002)(7696005)(99286004)(6246003)(55016002)(68736007)(5660300002)(4326008)(71190400001)(71200400001)(316002)(54906003)(86362001)(229853002)(72206003)(3846002)(305945005)(966005)(7736002)(6116002)(256004)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3199; H:VI1PR08MB3167.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sk6XvqsN5CXeZcNAZKm/knDOshk+G+a7VuMpUQ2IHt8WXfQx5KqjRD6Fsgz92QQk2Bh/YvC0hC7Hd0MPnvXevU+raRu2j0DWBwtssTUUk7YrW3RUJyXmlVjpS4jl70edxmL3CjlFxGhGfVZVvQtSkAPbUiPINutoxGHg1dq3I9xij4ACqYWZ7fZTu1yULHgOvRBReqapF5hXQBABcvRxWQuI1wdjLjMDC9oy8L+OWNst+iGpKky8PXibuqr2iFHdFqbl4KYg+nuSSCr/5YS6B+73O67YqWf5SoEdp34StRqCpMvZLtJzpZU95KEBNpji07LcQZzvwK+OModkp+i38fnyOZf1yCrILOdDhaqk/iNa+UzH5mw68rxP82Rgjpv7Dsr73+vhqhTlhiIuD0wsLZNhw2qGg/J0fiVfEFu+xNw= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5d2ab9c-1ee5-44bd-ea58-08d6fdf40fb8 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2019 07:16:39.5699 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Gavin.Hu@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3199 Subject: Re: [dpdk-dev] [RFC 1/5] eal: add the APIs to wait until equal X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Stephen, > -----Original Message----- > From: Stephen Hemminger > Sent: Monday, July 1, 2019 4:28 AM > To: Gavin Hu (Arm Technology China) > Cc: dev@dpdk.org; thomas@monjalon.net; jerinj@marvell.com; > hemant.agrawal@nxp.com; bruce.richardson@intel.com; > chaozhu@linux.vnet.ibm.com; Honnappa Nagarahalli > ; nd > Subject: Re: [dpdk-dev] [RFC 1/5] eal: add the APIs to wait until equal >=20 > On Mon, 1 Jul 2019 00:21:12 +0800 > Gavin Hu wrote: >=20 > > +#ifdef RTE_USE_WFE > > +#define rte_wait_until_equal_relaxed(addr, expected) do {\ > > + typeof(*addr) tmp; \ > > + if (__builtin_constant_p((expected))) \ > > + do { \ > > + if (sizeof(*(addr)) =3D=3D 16)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxrh %w0, %1\n" \ > > + "cmp %w0, %w2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r"(tmp) \ > > + : "Q"(*addr), "i"(expected) \ > > + : "cc", "memory"); \ > > + else if (sizeof(*(addr)) =3D=3D 32)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxr %w0, %1\n" \ > > + "cmp %w0, %w2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r"(tmp) \ > > + : "Q"(*addr), "i"(expected) \ > > + : "cc", "memory"); \ > > + else if (sizeof(*(addr)) =3D=3D 64)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxr %x0, %1\n" \ > > + "cmp %x0, %x2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r" (tmp) \ > > + : "Q"(*addr), "i"(expected) \ > > + : "cc", "memory"); \ > > + } while (0); \ > > + else \ > > + do { \ > > + if (sizeof(*(addr)) =3D=3D 16)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxrh %w0, %1\n" \ > > + "cmp %w0, %w2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r"(tmp) \ > > + : "Q"(*addr), "r"(expected) \ > > + : "cc", "memory"); \ > > + else if (sizeof(*(addr)) =3D=3D 32)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxr %w0, %1\n" \ > > + "cmp %w0, %w2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r"(tmp) \ > > + : "Q"(*addr), "r"(expected) \ > > + : "cc", "memory"); \ > > + else if (sizeof(*(addr)) =3D=3D 64)\ > > + asm volatile( \ > > + "sevl\n" \ > > + "1: wfe\n" \ > > + "ldxr %x0, %1\n" \ > > + "cmp %x0, %x2\n" \ > > + "bne 1b\n" \ > > + : "=3D&r" (tmp) \ > > + : "Q"(*addr), "r"(expected) \ > > + : "cc", "memory"); \ > > + } while (0); \ > > +} while (0) >=20 > That is a hot mess. > Macro's are harder to maintain and offer no benefit over inline functions= . During our internal review, I ever used C11 _Generic to generalize the API = to take different types of arguments.=20 That makes the API look much simpler and better, but it poses a hard requir= ement for C11 and gcc 4.9+. That means, Gaetan's patch, as shown below, has to be reverted, otherwise t= here are compiling errors. https://gcc.gnu.org/wiki/C11Status=20 $ git show ea7726a6 commit ea7726a6ee4b2b63313c4a198522a8dcea70c13d Author: Gaetan Rivet Date: Thu Jul 20 14:27:53 2017 +0200 net/failsafe: fix build on FreeBSD 10 with GCC 4.8 diff --git a/drivers/net/failsafe/Makefile b/drivers/net/failsafe/Makefile index 32aaaa2..d516d36 100644 --- a/drivers/net/failsafe/Makefile +++ b/drivers/net/failsafe/Makefile @@ -50,7 +50,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) +=3D failsafe_flow= .c # No exported include files # Basic CFLAGS: -CFLAGS +=3D -std=3Dc11 -Wextra +CFLAGS +=3D -std=3Dgnu99 -Wextra