From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00066.outbound.protection.outlook.com [40.107.0.66]) by dpdk.org (Postfix) with ESMTP id 8D40D8E01 for ; Wed, 20 Dec 2017 09:39:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Xaoba8yJgWHHzp7UmGMzC4fsgjNBSMK1qx2UdsQN8vc=; b=to0KUb7LeJCrg+3bYI17u78AyF8n9qMypu9svKC1BqKz7WVHl+w5Q/QAGqKhfi475eQiLQgx6IuYq03lmfynRGw2T1BFZm+uBBEaxbPu2PHrZmNGeR1sqBgmvi1VyxFdWJ30FbOApmwVpeBZVomuyB7pG4puj6KNGVtdH5/635A= Received: from HE1PR0502MB3659.eurprd05.prod.outlook.com (10.167.127.17) by HE1PR0502MB3660.eurprd05.prod.outlook.com (10.167.127.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 08:39:06 +0000 Received: from HE1PR0502MB3659.eurprd05.prod.outlook.com ([fe80::982e:2dce:9449:6891]) by HE1PR0502MB3659.eurprd05.prod.outlook.com ([fe80::982e:2dce:9449:6891%13]) with mapi id 15.20.0323.018; Wed, 20 Dec 2017 08:39:06 +0000 From: Matan Azrad To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= , Thomas Monjalon CC: Stephen Hemminger , Adrien Mazarguil , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check removal status Thread-Index: AQHTeOxa+4DzZLX6/kqsmyHoz/yjVKNK6W6AgAAAfmCAADptAIAAFvgAgACnd4A= Date: Wed, 20 Dec 2017 08:39:06 +0000 Message-ID: References: <1513175370-16583-1-git-send-email-matan@mellanox.com> <20171219092017.532d596f@xeon-e3> <20459625.d9rBa0iXI8@xps> <20171219221322.stibgas3ac2yxqjk@bidouze.vm.6wind.com> In-Reply-To: <20171219221322.stibgas3ac2yxqjk@bidouze.vm.6wind.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [85.64.81.213] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HE1PR0502MB3660; 6:OcbU7ApO85229OINY7RAfVZRZihJkwdJRudxKK9i3hAHX1V/0OHHS/qSbFQpZ1YozKVlBV6OTTrp+MugTUUPmf189VG11HOBrWZSVmSfr8c0hIf1BU9qz0G2+0s5V2So1zrjVu2oiR5543AZZSLoFgzVM/wvJ03nZugYmGjTEmxwj2h/KCF/ADX6vpZOSq10g8drLstRhiX+4Ehp6UcTJjXmaEfLrqjjIvlYR8FWfhhEYrTyClxwCSV2FB14YZi/RFhxvMEVYKIw/RTFsUqMWZ1J/SKnbDyw/EXhiqS5yB1AYxC+7F5W83vOP2nkW+jgSQ2OhrCR0vlu2YDJaE+FoOTyFoAEJxECc3g1OC2wC74=; 5:v7HMcCrNGGBdYnBDKMDMV1w8wHeuXbcWPmPbgdcB0Fl/QYMWz1rAXF9dUS0Eqm3ClszaDmUz0YqKPGRnN0Hf31mcggOTjVZ6xDIowkeUOSJwgolCjrQpjsAg6z0Tscv2mH0bCMFED+Hqh/I4ztoa+QiArGxaNy3OtN1SKjTGWt0=; 24:uKyGNhgtFGnK04/Y5qeQSOTvLo+iU1/+Wl80WN5hUYs0NbLRPiNZ9pLAsY4RTUk/bn6mG0LFCmM6gk40cUNtWQCUNfN/I0fYsUhPUshLb3c=; 7:aQQjiZPv5HJN1YaMnerIy31dqaWcSyW0ZPmSZwSmXoerXQk9IgV5AMjzhAl3UKw2GzC/Er0S+G4w67GTDoCUASKUEYFvxsl2Tjc4oW/KY6w7uWRGKZ+YJ3V2pCmZsNOSBiO9vn5s4zC/MdPkf9chJ8wf9RODpo2cixZ50XBwxZnnxwAE8qm+qppvKhURat9IQo3szAxn0sMer8D17/03u5YE2DlHwT7hi0aeOKtg03HwsZfBHvN2J9uY9odrYWGY x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 22b15fae-aae7-455c-1f42-08d5478521ce x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:HE1PR0502MB3660; x-ms-traffictypediagnostic: HE1PR0502MB3660: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93001095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:HE1PR0502MB3660; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0502MB3660; x-forefront-prvs: 0527DFA348 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(396003)(39380400002)(366004)(376002)(51444003)(76104003)(24454002)(13464003)(199004)(189003)(6116002)(33656002)(81156014)(105586002)(229853002)(53546011)(8936002)(66066001)(25786009)(9686003)(6436002)(6506007)(81166006)(5250100002)(8676002)(14454004)(55016002)(478600001)(4326008)(5660300001)(2900100001)(3280700002)(2906002)(3660700001)(6246003)(74316002)(68736007)(2950100002)(106356001)(53936002)(316002)(99286004)(54906003)(93886005)(3846002)(76176011)(7696005)(97736004)(305945005)(102836003)(7736002)(110136005)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3660; H:HE1PR0502MB3659.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22b15fae-aae7-455c-1f42-08d5478521ce X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2017 08:39:06.4453 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3660 Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check removal status 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: , X-List-Received-Date: Wed, 20 Dec 2017 08:39:08 -0000 Hi > -----Original Message----- > From: Ga=EBtan Rivet [mailto:gaetan.rivet@6wind.com] > Sent: Wednesday, December 20, 2017 12:13 AM > To: Thomas Monjalon > Cc: Matan Azrad ; Stephen Hemminger > ; Adrien Mazarguil > ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check removal > status >=20 > On Tue, Dec 19, 2017 at 09:51:10PM +0100, Thomas Monjalon wrote: > > 19/12/2017 18:24, Matan Azrad: > > > HI > > > > > > > -----Original Message----- > > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > > > Sent: Tuesday, December 19, 2017 7:20 PM > > > > To: Matan Azrad > > > > Cc: Adrien Mazarguil ; Thomas > Monjalon > > > > ; Gaetan Rivet ; > > > > dev@dpdk.org > > > > Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add devop to check > > > > removal status > > > > > > > > On Tue, 19 Dec 2017 17:10:10 +0000 Matan Azrad > > > > wrote: > > > > > > > > > int > > > > > +rte_eth_dev_is_removed(uint16_t port_id) { > > > > > + struct rte_eth_dev *dev; > > > > > + int ret; > > > > > + > > > > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); > > > > > + > > > > > + dev =3D &rte_eth_devices[port_id]; > > > > > + > > > > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > >is_removed, 0); > > > > > + > > > > > + if (dev->state =3D=3D RTE_ETH_DEV_REMOVED) > > > > > + return 1; > > > > > + > > > > > + ret =3D dev->dev_ops->is_removed(dev); > > > > > + if (ret !=3D 0) > > > > > + dev->state =3D RTE_ETH_DEV_REMOVED; > > > > > + > > > > > + return ret; > > > > > +} > > > > > + > > > > > > > > This looks good. > > > > May be a candidate to use bool instead of int for return value? > > > > > > Yes, I thought about it but didn't see any precedence for bool usage = in > ethdev APIs. > > > Guys, what do you think? > > > > I think this function can return error, isn't it? > > (look at macros *_OR_ERR_RET used in the function) > > >=20 > But those macros are used to return 0. >=20 > While I think I see a logic behind it, I think it is surprising the API u= ser, which is > not ideal. >=20 The logic behind it is that "is" semantic is question which expects to yes\= no answer. Therefore, user who uses this API just expects to either True or False retu= rn value and doesn't need to check more errors options like -ENODEV or -ENO= TSUP. I decided that the return value will be only 0 or 1 to make it easier to us= er: Removed - 1, Present - 0, No support - it makes sense that PMD which doesn't implement "is_removed" d= evop means that its underlying devices are not removable so they are always= present and this function should return '0' for it. No port - I think that '0' here will be better that '1'. Stephen suggestion to replace '0' and '1' by 'false' and 'true' makes sense= but I decided not to do it like this because of the next ideas: 1. No precedence for bool value in ethdev APIs. 2. Maybe it will be problematic to use *OR_ERR_RET defines to return bool v= alue.=20 I hope that this explanation helps you. Thanks,=20 Matan. =20 =20 =20 > -- > Ga=EBtan Rivet > 6WIND