From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 7B5F5A0096 for ; Thu, 6 Jun 2019 12:02:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B02181B998; Thu, 6 Jun 2019 12:02:38 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 007521B970 for ; Thu, 6 Jun 2019 12:02:36 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190606100235euoutp01182258f4994ce472f83b1b111444ba1d~lk81Ofhf-0400704007euoutp01_ for ; Thu, 6 Jun 2019 10:02:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190606100235euoutp01182258f4994ce472f83b1b111444ba1d~lk81Ofhf-0400704007euoutp01_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1559815355; bh=OFviOdyueiowIsJOK3FxfIG7Gm2rUI0FwSolAXSH7ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NEuOdq+3PWA+v9PE9oatrGqSth8PvhGsCeXxVCTgc/mlBmt/2FjGZYi3Pj+6lNv8z 7f9VwVWtfo0D7BQLLqa1OLXh9zJcMdAMDftsHU1BOC1WPts5zcerH7Dtsf8QWTWSJm 5FPqz/khV9Ti8XKWEZRAPg0JW+yVWSPL9i/Hxl7E= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190606100235eucas1p1303efd3e2f0bd0ca0a5c7e7b5651e6e8~lk80yIV4I0717907179eucas1p1L; Thu, 6 Jun 2019 10:02:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 73.CF.04325.BB4E8FC5; Thu, 6 Jun 2019 11:02:35 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190606100234eucas1p2a73029a37495cde21bce3b9a3b023ac4~lk8z-sKqg1094010940eucas1p22; Thu, 6 Jun 2019 10:02:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190606100234eusmtrp1b2981e39f1e1bb6b8cb58da0a62cb4ee~lk8zwKEER2585525855eusmtrp1e; Thu, 6 Jun 2019 10:02:34 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-c1-5cf8e4bbd73b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 00.B2.04140.AB4E8FC5; Thu, 6 Jun 2019 11:02:34 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190606100233eusmtip2480d1706243d570e2849238b4603137d~lk8zKVzpg3137731377eusmtip2U; Thu, 6 Jun 2019 10:02:33 +0000 (GMT) From: Ilya Maximets To: dev@dpdk.org Cc: Thomas Monjalon , Anatoly Burakov , Jan Blunck , Qi Zhang , Kevin Traynor , David Marchand , Ilya Maximets , stable@dpdk.org Date: Thu, 6 Jun 2019 13:02:28 +0300 Message-Id: <20190606100228.19959-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530132526.3496-1-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkleLIzCtJLcpLzFFi42LZduznOd3dT37EGMx+zmXx6N5iZovtK7rY LN592s5kcaX9J7tF68NWJou1hz6wW0zf0M9m8a/jD7vFpwcnWBw4PX4tWMrqsXmFlsfiPS+Z PI7dnMbu8X7fVTaPvi2rGAPYorhsUlJz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YuTiEBJYySlz/ 38nSxcgJFJeS+PHrAiuELSzx51oXG0TRN0aJFQf+MoMk2AR0JE6tPsIIYosICEh87lwMVsQs sJlJ4svkRiaQhLCAs8TUjVPAprIIqEpsmv0UbCqvgLVEz7XfjBAb5CVWbzgANpQTKL73dTNY r5CAlcSDzbPYJjDyLWBkWMUoklpanJueW2ykV5yYW1yal66XnJ+7iREY0tuO/dyyg7HrXfAh RgEORiUeXomN32OEWBPLiitzDzFKcDArifCWXfgRI8SbklhZlVqUH19UmpNafIjRFOioicxS osn5wHjLK4k3NDU0t7A0NDc2NzazUBLn7RA4GCMkkJ5YkpqdmlqQWgTTx8TBKdXA6PO9TaTr o3fsB3cFpRmHAyWKvNuui+2Qfrtqs0ts3fZ1YXcDC19WXln8IcK4mGOC+Oltvy9tP1Vz/+vc cImEbjbzhMnnvn10FnxgdiLm+2vevto2d+v3X++lJIaG/s98PsVsllxiFItt4/yFM8XPd7x/ rvnC4eSPWRfelojHFH2151+fkbNthxJLcUaioRZzUXEiAN4U9XN/AgAA X-CMS-MailID: 20190606100234eucas1p2a73029a37495cde21bce3b9a3b023ac4 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190606100234eucas1p2a73029a37495cde21bce3b9a3b023ac4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190606100234eucas1p2a73029a37495cde21bce3b9a3b023ac4 References: <20190530132526.3496-1-i.maximets@samsung.com> Subject: [dpdk-dev] [PATCH v2] eal: fix positive error codes from probe/remove 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" According to API, 'rte_dev_probe()' and 'rte_dev_remove()' must return 0 or negative error code. Bus code returns positive values if device wasn't recognized by any driver, so the result of 'bus->plug/unplug()' must be converted. 'local_dev_probe()' and 'local_dev_remove()' also has their internal API, so the conversion should be done there. Positive on remove means that device not found by driver. Positive on probe means that there are no suitable buses/drivers, i.e. device is not supported. Users of these API fixed to provide a good example by respecting DPDK API. This also will allow to catch such issues in the future. CC: stable@dpdk.org Fixes: a3ee360f4440 ("eal: add hotplug add/remove device") Fixes: 244d5130719c ("eal: enable hotplug on multi-process") Signed-off-by: Ilya Maximets --- Version 2: * Fixed API callers. * Check for probe moved from 'rte_dev_probe' to 'local_dev_probe'. app/test-pmd/testpmd.c | 4 ++-- drivers/net/failsafe/failsafe.c | 2 +- drivers/net/failsafe/failsafe_eal.c | 4 ++-- drivers/net/failsafe/failsafe_ether.c | 2 +- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 5 ++++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4f2a431e4..52244b442 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2361,7 +2361,7 @@ attach_port(char *identifier) return; } - if (rte_dev_probe(identifier) != 0) { + if (rte_dev_probe(identifier) < 0) { TESTPMD_LOG(ERR, "Failed to attach port %s\n", identifier); return; } @@ -2431,7 +2431,7 @@ detach_port_device(portid_t port_id) port_flow_flush(port_id); } - if (rte_dev_remove(dev) != 0) { + if (rte_dev_remove(dev) < 0) { TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name); return; } diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index e91c274d8..19dd71d4e 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -374,7 +374,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) } if (!devargs_already_listed(&devargs)) { ret = rte_dev_probe(devargs.name); - if (ret != 0) { + if (ret < 0) { ERROR("Failed to probe devargs %s", devargs.name); continue; diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index 820a915f7..b9fc50867 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -48,7 +48,7 @@ fs_bus_init(struct rte_eth_dev *dev) ret = rte_eal_hotplug_add(da->bus->name, da->name, da->args); - if (ret) { + if (ret < 0) { ERROR("sub_device %d probe failed %s%s%s", i, rte_errno ? "(" : "", rte_errno ? strerror(rte_errno) : "", @@ -147,7 +147,7 @@ fs_bus_uninit(struct rte_eth_dev *dev) FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { sdev_ret = rte_dev_remove(sdev->dev); - if (sdev_ret) { + if (sdev_ret < 0) { ERROR("Failed to remove requested device %s (err: %d)", sdev->dev->name, sdev_ret); continue; diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 4746fad36..504c76edb 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -284,7 +284,7 @@ fs_dev_remove(struct sub_device *sdev) /* fallthrough */ case DEV_PROBED: ret = rte_dev_remove(sdev->dev); - if (ret) { + if (ret < 0) { ERROR("Bus detach failed for sub_device %u", SUB_ID(sdev)); } else { diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index edab63e3a..1fcf90d7b 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -633,7 +633,7 @@ vdev_netvsc_netvsc_probe(const struct if_nameindex *iface, ctx->devname, ctx->devargs); vdev_netvsc_foreach_iface(vdev_netvsc_device_probe, 0, ctx); ret = rte_eal_hotplug_add("vdev", ctx->devname, ctx->devargs); - if (ret) + if (ret < 0) goto error; LIST_INSERT_HEAD(&vdev_netvsc_ctx_list, ctx, entry); ++vdev_netvsc_ctx_count; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 824b8f926..f8f2a94b3 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -172,6 +172,9 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) */ ret = dev->bus->plug(dev); + if (ret > 0) + ret = -ENOTSUP; + if (ret && !rte_dev_is_probed(dev)) { /* if hasn't ever succeeded */ RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); @@ -319,7 +322,7 @@ local_dev_remove(struct rte_device *dev) if (ret) { RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", dev->name); - return ret; + return (ret < 0) ? ret : -ENOENT; } return 0; -- 2.17.1