From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0069.outbound.protection.outlook.com [104.47.1.69]) by dpdk.org (Postfix) with ESMTP id CBFC42BF5 for ; Mon, 8 Jan 2018 13:55:50 +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=QZ3jPiSwezWkacvEMPugj6DFGd+utoyS0ckiXrPKiPM=; b=lu8d5U4sWT0ScbO7VKrf/ZCe4Co81TUTDnp4wab7iDy5LdhV9zA3NGpiOQpmyatFuGHETs0IPOR/k5SDRHqShXJOhqZ69x7jlwPx3JsIxScow1DYctljCT+MV3KJno25Ia0N7qKo6Gvt2DqeIUq4zXTW4o7h2cf+IY/y/nkFjfU= Received: from AM6PR0502MB3797.eurprd05.prod.outlook.com (52.133.21.26) by AM6PR0502MB3800.eurprd05.prod.outlook.com (52.133.21.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Mon, 8 Jan 2018 12:55:49 +0000 Received: from AM6PR0502MB3797.eurprd05.prod.outlook.com ([fe80::b4b4:7de8:cf70:aa3a]) by AM6PR0502MB3797.eurprd05.prod.outlook.com ([fe80::b4b4:7de8:cf70:aa3a%13]) with mapi id 15.20.0386.006; Mon, 8 Jan 2018 12:55:49 +0000 From: Matan Azrad To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: Adrien Mazarguil , Thomas Monjalon , "dev@dpdk.org" Thread-Topic: [PATCH v3 6/6] net/failsafe: fix removed device handling Thread-Index: AQHTeRfCVjig+VM1dkqFOSUojatLK6NMDewggB3e44CAAB0D8A== Date: Mon, 8 Jan 2018 12:55:49 +0000 Message-ID: References: <1513175370-16583-1-git-send-email-matan@mellanox.com> <1513703415-29145-1-git-send-email-matan@mellanox.com> <1513703415-29145-7-git-send-email-matan@mellanox.com> <20171219222131.plcfn5wqggyn5znw@bidouze.vm.6wind.com> <20180108105739.qkyejshupojkwyv2@bidouze.vm.6wind.com> In-Reply-To: <20180108105739.qkyejshupojkwyv2@bidouze.vm.6wind.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR0502MB3800; 7:sm/lx45T3NJ1Y22+PyN2ETWcfegCYXzsdR/x2ENLEGn/t75oghRxL5Wh62DJv1XoakiFELOQxaN+OZqggTutoGOtq/N8I+CA+xtfTBcDG3h4RoKRyettiKgtROuIouxA8ibkRIMID8gPA918GWwjzDDdoQbY2bJlvXlR7R7GYZDgs3PA7ELPhb7vEvJqNLKrBHq90/APdWkUUQZuazaYW4+hmmnw1OBrNe0LTCizE0jw5BbEX3rK9aW1mvshvKHE x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 04950b0a-b8ee-49ec-b3e3-08d556972493 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3800; x-ms-traffictypediagnostic: AM6PR0502MB3800: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(278428928389397); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231023)(944501075)(6055026)(6041268)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM6PR0502MB3800; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3800; x-forefront-prvs: 054642504A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(39380400002)(346002)(376002)(51444003)(13464003)(76104003)(51914003)(189003)(199004)(24454002)(6506007)(74316002)(229853002)(5250100002)(102836004)(59450400001)(66066001)(53546011)(55016002)(7736002)(53936002)(54906003)(305945005)(316002)(86362001)(93886005)(6436002)(2900100001)(9686003)(3660700001)(33656002)(2906002)(97736004)(6916009)(4326008)(3846002)(105586002)(81156014)(14454004)(8676002)(25786009)(3280700002)(68736007)(5660300001)(478600001)(99286004)(76176011)(8936002)(81166006)(7696005)(6116002)(6246003)(106356001)(2950100002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3800; H:AM6PR0502MB3797.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: p1LknJR/KfCgCaIe21/w7Bc9UVdsy9hALKAKmwbYCWZJV7hrOBrkAt0keveqpKWuidbxSpDSvPiZNXwfsR4Q/A== 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: 04950b0a-b8ee-49ec-b3e3-08d556972493 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2018 12:55:49.5253 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3800 Subject: Re: [dpdk-dev] [PATCH v3 6/6] net/failsafe: fix removed device handling 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: Mon, 08 Jan 2018 12:55:51 -0000 Hi Gaetan From: Ga=EBtan Rivet, Monday, January 8, 2018 12:58 PM > Hi Matan, >=20 > Sorry for the delay on this. >=20 It's OK in spite of I need to fetch it back :) > On Wed, Dec 20, 2017 at 10:58:29AM +0000, Matan Azrad wrote: > > Hi Gaetan > > > > > -----Original Message----- > > > From: Ga=EBtan Rivet [mailto:gaetan.rivet@6wind.com] > > > Sent: Wednesday, December 20, 2017 12:22 AM > > > To: Matan Azrad > > > Cc: Adrien Mazarguil ; Thomas Monjalon > > > ; dev@dpdk.org > > > Subject: Re: [PATCH v3 6/6] net/failsafe: fix removed device > > > handling > > > > > > Hi Matan, > > > > > > On Tue, Dec 19, 2017 at 05:10:15PM +0000, Matan Azrad wrote: > > > > There is time between the physical removal of the device until > > > > sub-device PMDs get a RMV interrupt. At this time DPDK PMDs and > > > > applications still don't know about the removal and may call > > > > sub-device control operation which should return an error. > > > > > > > > In previous code this error is reported to the application > > > > contrary to fail-safe principle that the app should not be aware of > device removal. > > > > > > > > Add an removal check in each relevant control command error flow > > > > and prevent an error report to application when the sub-device is > removed. > > > > > > > > Fixes: a46f8d5 ("net/failsafe: add fail-safe PMD") > > > > Fixes: b737a1e ("net/failsafe: support flow API") >=20 > As stated previously, please do not include those fixes lines. >=20 > > > > > > > > Signed-off-by: Matan Azrad > > > > --- > > > > > > > > > > > > > +/* > > > > + * Check if error should be reported to the user. > > > > + */ > > > > +static inline bool > > > > +fs_is_error(struct sub_device *sdev, int err) { > > > > + /* A device removal shouldn't be reported as an error. */ > > > > + if (err =3D=3D 0 || sdev->remove =3D=3D 1 || err =3D=3D -EIO) > > > > + return false; > > > > + return true; > > > > +} > > > > > > This is better, thanks. > > > > > > However is there a reason you did not follow the same pattern as > > > ethdev with eth_err? I see the two functions as similar in their > > > intent, making them close to each other would be clearer to a reader > > > being familiar with the ethdev API and that would be interested in fa= il- > safe. > > > > > > What do you think? > > > > > > > I think that there is a real different between eth_err function to > fs_is_error: > > ethdev uses eth_err function to adjust removal return value to be -EIO. > > fail-safe uses fs_is_error function to check if an error should be repo= rted to > the user to save the fail-safe principle that the app should not be aware= of > device removal - this is the main idea that also causes me to change th= e > name from fs_is_removed to fs_is_error. >=20 > I would have preferred if it followed the same pattern as ethdev (that > function be used to adjust the return value, not performing a flag check)= . >=20 > While better on its own, the pattern: >=20 > if (fs_is_error(sdev, err)) { > ERROR("xxxx"); > return err; > } >=20 > is dangerous, as then the author is forbidden from returning err, assumin= g > err could be -EIO. He or she would be forced to return an explicit "0". > To be clear, here would be an easy mistake to do: >=20 > if (fs_is_error(sdev, err)) { > ERROR("xxxx"); > } > return err; >=20 > And this kind of code-flow is not unusual, or even unwanted. > I dislike having this kind of implicit rule derived from using a helper s= uch as > fs_is_error(). >=20 > The alternative >=20 > if ((err =3D fs_err(sdev, err))) { > ERROR("xxxx"); > return err; > } >=20 > Forces the value err to be set to the correct one. >=20 Good point, will change it. > This mistake can already be found in your patch: >=20 > > @@ -150,7 +150,7 @@ > > continue; > > local_ret =3D rte_flow_destroy(PORT_ID(sdev), > > flow->flows[i], error); > > - if (local_ret) { > > + if (fs_is_error(sdev, local_ret)) { > > ERROR("Failed to destroy flow on sub_device %d:= %d", > > i, local_ret); > > if (ret =3D=3D 0) >=20 Sorry, I can't see any issue here. > Your environment does not include the function, but this is within > fs_flow_destroy (please update to include the context by the way it helps= a > lot the review :). Afterward, line 162 ret is directly used as return val= ue. >=20 I don't understand what do you mean. > Also, fs_err() would need to transform rte_errno when relevant (mostly in > failsafe_flow.c I think). >=20 Your suggestion is always to update rte_errno to 0 in case the error is bec= ause of removal? > This is the kind of subtlety that needs to be avoided when designing APIs= , > even internal ones. This will induce errors afterward and complicate the > maintenance of the codebase. > Thanks for the lesson!=20 =20 > Best regards, >=20 > -- > Ga=EBtan Rivet > 6WIND