From patchwork Thu Jun 25 08:04:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 72170 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 60536A0350; Thu, 25 Jun 2020 10:04:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB6081B75C; Thu, 25 Jun 2020 10:04:51 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id CBAF11B5E1 for ; Thu, 25 Jun 2020 10:04:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593072290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+I+uUPEURxHm7aFn6vjMooRstSLyqRfRTUiHB5HTN0=; b=Nkx5Gppd+t1/+0F+EpWhcLYso/IbM6UXFHCbElscW2xgCqA91Zk44EUu0qy34YDzYi/105 iaf1QD/8Wg3sfc20RajzLgzf6H/+Hio2IZdiGHCopSM1qNeq85GHeYtbEO7WbQSVEUCJQw EDoQwhoidDBxnI5XWJwa7SlOUSn6fjc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-4a2t7N11MuaVRMmLsHJO-g-1; Thu, 25 Jun 2020 04:04:46 -0400 X-MC-Unique: 4a2t7N11MuaVRMmLsHJO-g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4205E804002; Thu, 25 Jun 2020 08:04:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D48B1017E27; Thu, 25 Jun 2020 08:04:43 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, grive@u256.net, david.marchand@redhat.com, wenzhuo.lu@intel.com, beilei.xing@intel.com, bernard.iremonger@intel.com Cc: Maxime Coquelin Date: Thu, 25 Jun 2020 10:04:29 +0200 Message-Id: <20200625080430.1392037-2-maxime.coquelin@redhat.com> In-Reply-To: <20200625080430.1392037-1-maxime.coquelin@redhat.com> References: <20200625080430.1392037-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 1/2] doc: announce rte_dev_probe() API change 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" In order to simplify the use of rte_dev_probe() and rte_dev_remove() by applications, rte_dev_probe() will return a reference on the rte_device stating DPDK v20.11. Signed-off-by: Maxime Coquelin Acked-by: Bruce Richardson Acked-by: Gaetan Rivet Acked-by: David Marchand Acked-by: Jerin Jacob --- doc/guides/rel_notes/deprecation.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index d1034f60fd..8661a673b5 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -130,3 +130,8 @@ Deprecation Notices Python 2 support will be completely removed in 20.11. In 20.08, explicit deprecation warnings will be displayed when running scripts with Python 2. + +* eal: Change ``rte_dev_probe`` API in DPDK v20.11 to return a pointer on the + probed rte_device or NULL instead of 0 or an error code. This change will + allow applications avoid iterating on devices after a probe to get access to + the new rte_device. From patchwork Thu Jun 25 08:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 72171 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1B6FDA0350; Thu, 25 Jun 2020 10:05:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EE601BC25; Thu, 25 Jun 2020 10:04:54 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 3B5E01B951 for ; Thu, 25 Jun 2020 10:04:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593072291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zy9SX9HLBxDU8NCQGVsonMwEDQG7tr3qWyOBC9+151s=; b=iqeJeGwszEtWHtsjEqOlpzi9jpMyXuYJT1NB4qOut4/enuMjnpVMUATLQaf36D7dHlkCww LCuYX9Iojfuzpa/xRZqP4IMo+XK3zA9WxMrEWr1d35VgFngwkgLPf9HWVlQBsNYNq0M/LO +4zFBpj9bF/mlJN+x9LgE/MVJRheSZA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-uGNMfjTkPOyzhUdEotUGeA-1; Thu, 25 Jun 2020 04:04:48 -0400 X-MC-Unique: uGNMfjTkPOyzhUdEotUGeA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE158BFC4; Thu, 25 Jun 2020 08:04:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC564100EBA4; Thu, 25 Jun 2020 08:04:45 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, grive@u256.net, david.marchand@redhat.com, wenzhuo.lu@intel.com, beilei.xing@intel.com, bernard.iremonger@intel.com Cc: Maxime Coquelin Date: Thu, 25 Jun 2020 10:04:30 +0200 Message-Id: <20200625080430.1392037-3-maxime.coquelin@redhat.com> In-Reply-To: <20200625080430.1392037-1-maxime.coquelin@redhat.com> References: <20200625080430.1392037-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 (v20.11) 2/2] eal: improve device probing API 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" This patch makes rte_dev_probe() to return the rte_device pointer on success and NULL on error instead of returning 0 on success and negative value on error. The goal is to avoid that the calling application iterates the devices list afterwards to retrieve the pointer. Retrieving the pointer is required for calling rte_dev_remove() later. Signed-off-by: Maxime Coquelin --- app/test-pmd/testpmd.c | 2 +- drivers/net/failsafe/failsafe.c | 5 +++-- lib/librte_eal/common/eal_common_dev.c | 18 ++++++++++-------- lib/librte_eal/include/rte_dev.h | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4989d22ca8..f777f449a8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2764,7 +2764,7 @@ attach_port(char *identifier) return; } - if (rte_dev_probe(identifier) < 0) { + if (rte_dev_probe(identifier) == NULL) { TESTPMD_LOG(ERR, "Failed to attach port %s\n", identifier); return; } diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 72362f35de..e32effdef2 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -341,6 +341,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) struct rte_eth_dev *eth_dev; struct sub_device *sdev; struct rte_devargs devargs; + struct rte_device *dev; uint8_t i; int ret; @@ -378,8 +379,8 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) continue; } if (!devargs_already_listed(&devargs)) { - ret = rte_dev_probe(devargs.name); - if (ret < 0) { + dev = rte_dev_probe(devargs.name); + if (dev == NULL) { ERROR("Failed to probe devargs %s", devargs.name); continue; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 9e4f09d83e..72baae2e48 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -120,7 +120,9 @@ rte_eal_hotplug_add(const char *busname, const char *devname, if (ret != 0) return ret; - ret = rte_dev_probe(devargs); + if (rte_dev_probe(devargs) == NULL) + ret = -1; + free(devargs); return ret; @@ -192,7 +194,7 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) return ret; } -int +struct rte_device * rte_dev_probe(const char *devargs) { struct eal_dev_mp_req req; @@ -212,12 +214,12 @@ rte_dev_probe(const char *devargs) if (ret != 0) { RTE_LOG(ERR, EAL, "Failed to send hotplug request to primary\n"); - return -ENOMSG; + return NULL; } if (req.result != 0) RTE_LOG(ERR, EAL, "Failed to hotplug add device\n"); - return req.result; + return NULL; } /* attach a shared device from primary start from here: */ @@ -236,7 +238,7 @@ rte_dev_probe(const char *devargs) * process. */ if (ret != -EEXIST) - return ret; + return dev; } /* primary send attach sync request to secondary. */ @@ -261,11 +263,11 @@ rte_dev_probe(const char *devargs) /* for -EEXIST, we don't need to rollback. */ if (ret == -EEXIST) - return ret; + return dev; goto rollback; } - return 0; + return dev; rollback: req.t = EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK; @@ -282,7 +284,7 @@ rte_dev_probe(const char *devargs) "Failed to rollback device attach on primary." "Devices in secondary may not sync with primary\n"); - return ret; + return NULL; } int diff --git a/lib/librte_eal/include/rte_dev.h b/lib/librte_eal/include/rte_dev.h index c8d985fb5c..9cf7c7fd71 100644 --- a/lib/librte_eal/include/rte_dev.h +++ b/lib/librte_eal/include/rte_dev.h @@ -148,9 +148,9 @@ int rte_eal_hotplug_add(const char *busname, const char *devname, * @param devargs * Device arguments including bus, class and driver properties. * @return - * 0 on success, negative on error. + * Generic device pointer on success, NULL on error. */ -int rte_dev_probe(const char *devargs); +struct rte_device *rte_dev_probe(const char *devargs); /** * Hotplug remove a given device from a specific bus.