From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 489842C28 for ; Sun, 7 Oct 2018 11:32:55 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 05B6621EE9; Sun, 7 Oct 2018 05:32:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 05:32:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=rS4eiMx5vM aTHBI5zrH2eZF/dm5kBO2k92ZjCpZ+IPE=; b=ltRh46pDiUoTRS21N/PYTXAjvq vtEDSdExeru4SKpzeZOgiT5xv7LMB1Lje/vqBSZbv6P1Y0E8aIoS7a5RPqdePjJZ RnhShiU6XTZN1jVxlxHpot3HPaQJ0blBHBwl9Qup1SrqtuNe1D8/cUAu1Y3rpa+1 nfu0NwTfOgSKwQlmg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=rS4eiMx5vMaTHBI5zrH2eZF/dm5kBO2k92ZjCpZ+IPE=; b=oGjxJdJl 8PAZnjhPDJBrS2QhwZmBPxmuLXRKHTKt5n+SaFYEWKWEt8hiLx0KyHzsOghWM5cG vnLsrQHUyks0oMqTjaq5pKSBq80mSMunq5fBVMAv5nnztAzl5XYZvxJalFZSlTWf C13Isrh38QaVEERqEwE4Vtrtzkp9SAIWZapOY37bxhW3PthtUPyhFcfdF/0YoK5f bCp2sC+AGM1dI0oBJ0uYfopuU6DUbM+YclFjxorexHIYu1En9vDzXnuj05cqYLcd v1eBdzMoABCJ1yaMT9Xbi4ndqay+z+TsX6kR/+BS053Ja9TXgAEOLRNoE1+nONkg 0Y2HcyIfD1CL/w== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id EB988102E8; Sun, 7 Oct 2018 05:32:52 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, qi.z.zhang@intel.com, ferruh.yigit@intel.com, ktraynor@redhat.com Date: Sun, 7 Oct 2018 11:32:41 +0200 Message-Id: <20181007093244.20659-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007093244.20659-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20181007093244.20659-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 2/5] devargs: simplify parameters of removal function 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: Sun, 07 Oct 2018 09:32:55 -0000 The function rte_devargs_remove(), which is intended to be internal, can take a devargs structure as argument. The matching is still using string comparison of bus name and device name. It is simpler and may allow a different devargs matching in future. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Acked-by: Gaetan Rivet --- doc/guides/rel_notes/release_18_11.rst | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 5 +---- drivers/bus/vdev/vdev.c | 8 ++------ lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 11 +++++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index 4f4420ad3..d534bb71c 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -123,6 +123,9 @@ API Changes ``rte_eal_parse_devargs_str()``, ``rte_eal_devargs_add()``, ``rte_eal_devargs_type_count()``, and ``rte_eal_devargs_dump()``. +* eal: The parameters of the function ``rte_devargs_remove()`` have changed + from bus and device names to ``struct rte_devargs``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index c54b59db2..3ef035b7e 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -361,7 +361,6 @@ static int ifpga_unplug(struct rte_device *dev) { struct rte_afu_device *afu_dev = NULL; - struct rte_devargs *devargs = NULL; int ret; if (dev == NULL) @@ -371,15 +370,13 @@ ifpga_unplug(struct rte_device *dev) if (!afu_dev) return -ENOENT; - devargs = dev->devargs; - ret = ifpga_remove_driver(afu_dev); if (ret) return ret; TAILQ_REMOVE(&ifpga_afu_dev_list, afu_dev, next); - rte_devargs_remove(devargs->bus->name, devargs->name); + rte_devargs_remove(dev->devargs); free(afu_dev); return 0; diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index ef3ad6d99..efca962f7 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -249,7 +249,6 @@ int rte_vdev_init(const char *name, const char *args) { struct rte_vdev_device *dev; - struct rte_devargs *devargs; int ret; rte_spinlock_recursive_lock(&vdev_device_list_lock); @@ -260,9 +259,8 @@ rte_vdev_init(const char *name, const char *args) if (ret > 0) VDEV_LOG(ERR, "no driver found for %s", name); /* If fails, remove it from vdev list */ - devargs = dev->device.devargs; TAILQ_REMOVE(&vdev_device_list, dev, next); - rte_devargs_remove(devargs->bus->name, devargs->name); + rte_devargs_remove(dev->device.devargs); free(dev); } } @@ -290,7 +288,6 @@ int rte_vdev_uninit(const char *name) { struct rte_vdev_device *dev; - struct rte_devargs *devargs; int ret; if (name == NULL) @@ -309,8 +306,7 @@ rte_vdev_uninit(const char *name) goto unlock; TAILQ_REMOVE(&vdev_device_list, dev, next); - devargs = dev->device.devargs; - rte_devargs_remove(devargs->bus->name, devargs->name); + rte_devargs_remove(dev->device.devargs); free(dev); unlock: diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 678dbcac7..e1d9e8ec7 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -186,7 +186,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn return 0; err_devarg: - if (rte_devargs_remove(busname, devname)) { + if (rte_devargs_remove(da) != 0) { free(da->args); free(da); } @@ -227,7 +227,7 @@ rte_eal_hotplug_remove(const char *busname, const char *devname) if (ret) RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", dev->name); - rte_devargs_remove(busname, devname); + rte_devargs_remove(dev->devargs); return ret; } diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 5cb5c624d..69e9e32e9 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -263,7 +263,7 @@ rte_devargs_insert(struct rte_devargs *da) { int ret; - ret = rte_devargs_remove(da->bus->name, da->name); + ret = rte_devargs_remove(da); if (ret < 0) return ret; TAILQ_INSERT_TAIL(&devargs_list, da, next); @@ -309,14 +309,17 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) } int __rte_experimental -rte_devargs_remove(const char *busname, const char *devname) +rte_devargs_remove(struct rte_devargs *devargs) { struct rte_devargs *d; void *tmp; + if (devargs == NULL || devargs->bus == NULL) + return -1; + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { - if (strcmp(d->bus->name, busname) == 0 && - strcmp(d->name, devname) == 0) { + if (strcmp(d->bus->name, devargs->bus->name) == 0 && + strcmp(d->name, devargs->name) == 0) { TAILQ_REMOVE(&devargs_list, d, next); free(d->args); free(d); diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 0eef6e9c4..b1f121f83 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -176,11 +176,8 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str); * Its resources are freed. * If the devargs cannot be found, nothing happens. * - * @param busname - * bus name of the devargs to remove. - * - * @param devname - * device name of the devargs to remove. + * @param devargs + * The instance or a copy of devargs to remove. * * @return * 0 on success. @@ -188,8 +185,7 @@ int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str); * >0 if the devargs was not within the user device list. */ __rte_experimental -int rte_devargs_remove(const char *busname, - const char *devname); +int rte_devargs_remove(struct rte_devargs *devargs); /** * Count the number of user devices of a specified type -- 2.19.0