From patchwork Wed Sep 26 21:47:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 45460 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 535531B474; Wed, 26 Sep 2018 23:48:16 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 4FBC91B2B0 for ; Wed, 26 Sep 2018 23:48:13 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E995521CE2; Wed, 26 Sep 2018 17:48:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 26 Sep 2018 17:48:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=bpNv3SfBwYzcQNGrGrD94/QyI0MxAy7QvzSFFh uHMRo=; b=rw7C+4uyzulsQeZqWhNriHaLU8t054C1fWNR8GaaPPP5p14xbsol8W a6KlEBKnQZXRY84sOEe7cG19286QiPaBdJXe0XP8dKCIqw+8/2VfEqmXLljNrXpT ftBMzc6oapQjgXSkHhsYYHWArYUr/ReDXrgqNbgnZzlqnJmMo3oJI= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=bpNv3SfBwYzcQNGrG rD94/QyI0MxAy7QvzSFFhuHMRo=; b=Fen9s55ydywMm877AGsw/Bi/vM5IzZSMV qKXIXnilHIyqfB1Ej4ZT5MD3VGQwBtljmaviWX0GmhVTwoGkNgIuZ/CizjQbvFv6 cU19oydEBnjOpZ4eUuCW4R4ZUHmIRQqLo8hTLATPHHFFhfig8bpwCyCGNW8Yw8lJ etuk/U10alNf4r0vnX+g58TPhN2ZwGox33NeXPmi2aBzjfyhlIALOObmvRX7v9rK PeI7w1Z7zEOm2lnDlke5KFUvh7GYQMg2NIknPq+W4ue5JeY+Mg6Xjy6dI2Jena1b DWxGge3smpfcEuZZS0OsPn7qKnXQHgFRPDtSx2eODAngvawavb+GA== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id DC77B102D6; Wed, 26 Sep 2018 17:48:11 -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: Wed, 26 Sep 2018 23:47:56 +0200 Message-Id: <20180926214759.1856-2-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926214759.1856-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20180926214759.1856-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/4] devargs: remove deprecated functions 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" rte_eal_parse_devargs_str() does not support parsing the bus name at the start of devargs. So it has been renamed and deprecated. rte_eal_devargs_add(), rte_eal_devargs_type_count() and rte_eal_devargs_dump() were declared deprecated and had their implementation body renamed. All these functions were deprecated in release 18.05. Signed-off-by: Thomas Monjalon --- The library version is not updated because it should be done in earlier patch https://patches.dpdk.org/patch/43903/ --- lib/librte_eal/common/eal_common_devargs.c | 30 --------- lib/librte_eal/common/include/rte_devargs.h | 71 --------------------- lib/librte_eal/rte_eal_version.map | 4 -- 3 files changed, 105 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index dac2402a4..f63d2c663 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -31,36 +31,6 @@ TAILQ_HEAD(rte_devargs_list, rte_devargs); struct rte_devargs_list devargs_list = TAILQ_HEAD_INITIALIZER(devargs_list); -int -rte_eal_parse_devargs_str(const char *devargs_str, - char **drvname, char **drvargs) -{ - char *sep; - - if ((devargs_str) == NULL || (drvname) == NULL || (drvargs == NULL)) - return -1; - - *drvname = strdup(devargs_str); - if (*drvname == NULL) - return -1; - - /* set the first ',' to '\0' to split name and arguments */ - sep = strchr(*drvname, ','); - if (sep != NULL) { - sep[0] = '\0'; - *drvargs = strdup(sep + 1); - } else { - *drvargs = strdup(""); - } - - if (*drvargs == NULL) { - free(*drvname); - *drvname = NULL; - return -1; - } - return 0; -} - static size_t devargs_layer_count(const char *s) { diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 097a4ce7b..0eef6e9c4 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -66,36 +66,6 @@ struct rte_devargs { const char *data; /**< Device string storage. */ }; -/** - * @deprecated - * Parse a devargs string. - * - * For PCI devices, the format of arguments string is "PCI_ADDR" or - * "PCI_ADDR,key=val,key2=val2,...". Examples: "08:00.1", "0000:5:00.0", - * "04:00.0,arg=val". - * - * For virtual devices, the format of arguments string is "DRIVER_NAME*" - * or "DRIVER_NAME*,key=val,key2=val2,...". Examples: "net_ring", - * "net_ring0", "net_pmdAnything,arg=0:arg2=1". - * - * The function parses the arguments string to get driver name and driver - * arguments. - * - * @param devargs_str - * The arguments as given by the user. - * @param drvname - * The pointer to the string to store parsed driver name. - * @param drvargs - * The pointer to the string to store parsed driver arguments. - * - * @return - * - 0 on success - * - A negative value on error - */ -__rte_deprecated -int rte_eal_parse_devargs_str(const char *devargs_str, - char **drvname, char **drvargs); - /** * Parse a device string. * @@ -201,23 +171,6 @@ rte_devargs_insert(struct rte_devargs *da); __rte_experimental int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str); -/** - * @deprecated - * Add a device to the user device list - * See rte_devargs_parse() for details. - * - * @param devtype - * The type of the device. - * @param devargs_str - * The arguments as given by the user. - * - * @return - * - 0 on success - * - A negative value on error - */ -__rte_deprecated -int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str); - /** * Remove a device from the user device list. * Its resources are freed. @@ -251,20 +204,6 @@ __rte_experimental unsigned int rte_devargs_type_count(enum rte_devtype devtype); -/** - * @deprecated - * Count the number of user devices of a specified type - * - * @param devtype - * The type of the devices to counted. - * - * @return - * The number of devices. - */ -__rte_deprecated -unsigned int -rte_eal_devargs_type_count(enum rte_devtype devtype); - /** * This function dumps the list of user device and their arguments. * @@ -274,16 +213,6 @@ rte_eal_devargs_type_count(enum rte_devtype devtype); __rte_experimental void rte_devargs_dump(FILE *f); -/** - * @deprecated - * This function dumps the list of user device and their arguments. - * - * @param f - * A pointer to a file for output - */ -__rte_deprecated -void rte_eal_devargs_dump(FILE *f); - /** * Find next rte_devargs matching the provided bus name. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 73282bbb0..3df7f9831 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -19,9 +19,6 @@ DPDK_2.0 { rte_dump_tailq; rte_eal_alarm_cancel; rte_eal_alarm_set; - rte_eal_devargs_add; - rte_eal_devargs_dump; - rte_eal_devargs_type_count; rte_eal_get_configuration; rte_eal_get_lcore_state; rte_eal_get_physmem_size; @@ -32,7 +29,6 @@ DPDK_2.0 { rte_eal_lcore_role; rte_eal_mp_remote_launch; rte_eal_mp_wait_lcore; - rte_eal_parse_devargs_str; rte_eal_process_type; rte_eal_remote_launch; rte_eal_tailq_lookup; From patchwork Wed Sep 26 21:47:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 45461 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6E621B471; Wed, 26 Sep 2018 23:48:22 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 222681B45F for ; Wed, 26 Sep 2018 23:48:14 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C453D21FF9; Wed, 26 Sep 2018 17:48:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 26 Sep 2018 17:48:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=JeoAFDR0HO7NK5QMSiMF3MWvnYAQQStwMhbNRq RGmbM=; b=dPQpKgYZZ5DmPGZr7tsJszM+OOGa+7HIYotEkUnZ4JG7SlO+FKQU2u 4cle18GoKe7BXvVkBmYT6F3xNKxEBk6hmRCToOHxnc16WQJiQrIx2byjqrcPdSb/ W3eiZ/T2hZDq17K4tlfF66miYxfRA9Z+Gse31Rq1lYJJAI/laghcU= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=JeoAFDR0HO7NK5QMS iMF3MWvnYAQQStwMhbNRqRGmbM=; b=jy+9gfViripPetUlH0BYLiBEEiR+cEo1s H2bcDiQTWxiXtxc//Oss9vLWM1Ayv5cg+wAjT9JEUp8YBYejefc5ijmveOqDmm+H ufzStjprVnC/BRttgtdjcdd+lwW9czF7ng3DCk39ndteRB8nUN6IMb5IFtH1904J odmruq04S8J0RS6FqsyaUxQO1SiBl1D6UYABYRlh75Fbtei/KGwRoOwfbX4c5rd7 A8oUkAj3xWfl+GCw10IqSmH25FswQ+vcfLSSL8QTRUTpV+9atRi9gvFlzorwNVYU gtMImLHBFL+7Xno+EZbI7F8XEoLR3rQdJ2aLB++ZL0hU1llDJkMhg== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id C0C04102D3; Wed, 26 Sep 2018 17:48:12 -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: Wed, 26 Sep 2018 23:47:57 +0200 Message-Id: <20180926214759.1856-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926214759.1856-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20180926214759.1856-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/4] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 | 8 ++++---- lib/librte_eal/common/include/rte_devargs.h | 10 +++------- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index b324872ee..0e17ea9a3 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -363,7 +363,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) @@ -373,15 +372,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 69dee89a8..390c2ce70 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -248,7 +248,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); @@ -259,9 +258,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); } } @@ -289,7 +287,6 @@ int rte_vdev_uninit(const char *name) { struct rte_vdev_device *dev; - struct rte_devargs *devargs; int ret; if (name == NULL) @@ -308,8 +305,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..e81ff4258 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)) { 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 f63d2c663..2f2bb4d90 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -266,7 +266,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); @@ -312,14 +312,14 @@ 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; 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 From patchwork Wed Sep 26 21:47:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 45462 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A21D01B48D; Wed, 26 Sep 2018 23:48:24 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 0802E1B45F for ; Wed, 26 Sep 2018 23:48:15 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id AA1472203B; Wed, 26 Sep 2018 17:48:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 26 Sep 2018 17:48:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=BHsK3e+EXoYCWsjaLRUwwm1t6m9Ewk7xS3/gEv f8Hig=; b=AN4bVASxAB0aGnLej2OykCYlQLAtsOUTORUQcWm6FXUi4GQ/q8QlOn gCVfGTaTIvK2ryTF0PZuid/g/uecxGgZRl64pJbKGtrYtigXKxQ4p6i5oHZ2R54K dvdY7KC2MDBTkX2/JQph1pEEYHdVTAMFi1fWheXfO5YbfRFM/wNMU= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=BHsK3e+EXoYCWsjaL RUwwm1t6m9Ewk7xS3/gEvf8Hig=; b=FcFfRgGY6Il5d86FX1xQ3H/tA9I7eWggq KrFTux59o/wdE71KegfJ59VjOQcZp9dXXqmmKMxXbIIL/UDVP89V2XD/hHVyh6hb LPD/3nyWsq7UbZT5efO0GR85DdhIFtl0AufWLtX2IgARwPZIPV5cB2CFiswX34Yc 5ptoBzYvjDAqTtoRLVI5v2pvo9mGHrMBIJoBLvc3KDd++28xSX11GlZmCgNkzBg5 q80QD8pEpMWwCnbmE293KYKuQPfY+VaiiFteSmtIAfikTwqSXVhYvSGPXH3Nihyv GanOQVhiXm6X+pTBZawMPTsp8A6bxvlceN7dj9ateo1LzhwKOK//Q== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A9A37102D2; Wed, 26 Sep 2018 17:48:13 -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: Wed, 26 Sep 2018 23:47:58 +0200 Message-Id: <20180926214759.1856-4-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926214759.1856-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20180926214759.1856-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 3/4] eal: remove experimental flag of hotplug functions 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" These functions are quite old and are the only available replacement for the deprecated attach/detach functions. Note: some new functions may (again) replace these hotplug functions, in future, with better parameters. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/eal_common_dev.c | 7 ++++--- lib/librte_eal/common/include/rte_dev.h | 13 +++---------- lib/librte_eal/rte_eal_version.map | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index e81ff4258..43fdab395 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -127,8 +127,9 @@ int rte_eal_dev_detach(struct rte_device *dev) return ret; } -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, - const char *devargs) +int +rte_eal_hotplug_add(const char *busname, const char *devname, + const char *devargs) { struct rte_bus *bus; struct rte_device *dev; @@ -193,7 +194,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn return ret; } -int __rte_experimental +int rte_eal_hotplug_remove(const char *busname, const char *devname) { struct rte_bus *bus; diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index b80a80598..4f5282459 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -189,9 +189,6 @@ __rte_deprecated int rte_eal_dev_detach(struct rte_device *dev); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * * Hotplug add a given device to a specific bus. * * @param busname @@ -204,13 +201,10 @@ int rte_eal_dev_detach(struct rte_device *dev); * @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname, - const char *devargs); +int rte_eal_hotplug_add(const char *busname, const char *devname, + const char *devargs); /** - * @warning - * @b EXPERIMENTAL: this API may change without prior notice - * * Hotplug remove a given device from a specific bus. * * @param busname @@ -220,8 +214,7 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn * @return * 0 on success, negative on error. */ -int __rte_experimental rte_eal_hotplug_remove(const char *busname, - const char *devname); +int rte_eal_hotplug_remove(const char *busname, const char *devname); /** * Device comparison function. diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 3df7f9831..6bff37f4b 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -261,6 +261,8 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_eal_hotplug_add; + rte_eal_hotplug_remove; rte_strscpy; } DPDK_18.08; @@ -288,8 +290,6 @@ EXPERIMENTAL { rte_devargs_remove; rte_devargs_type_count; rte_eal_cleanup; - rte_eal_hotplug_add; - rte_eal_hotplug_remove; rte_fbarray_attach; rte_fbarray_destroy; rte_fbarray_detach; From patchwork Wed Sep 26 21:47:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 45463 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 056CB1B495; Wed, 26 Sep 2018 23:48:27 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 5E0731B476 for ; Wed, 26 Sep 2018 23:48:16 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B3BC522012; Wed, 26 Sep 2018 17:48:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 26 Sep 2018 17:48:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=98beZJkfU9s9fKJaJqKU66PYXrBmnCd+EQEthx pdOvY=; b=cbOTYn8oLcCGj5TMaGdYhJPl//OPGup5EQLk//Ag+5ZGYTNj3EkWar u5Ce8v1s0vSzYSggduuu+JyeT5fT0NhYqCRbZSVKyrrmZgu0ADkE6kmCAUcJ8RXJ Iw0cNG3DmCtVuXMpfgIQJDUNysk6sGqfYD5dfVf80mjedgPZoBHMA= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=98beZJkfU9s9fKJaJ qKU66PYXrBmnCd+EQEthxpdOvY=; b=mADttBm0gh7g+pZXO0t26pjweetn8xZ/2 M0YSFKvSWKZY32PAy6Wn59JGGLZkJOL/Q18obuDAH4cT2Infj90YhK1qJ1cUtBnb j+SfAXOYcsMfPJiLlhxKcvoLvLe8l636ZP2uGkOTv7/hW2px3VjhATbrYBMnjP0V baQDjbGxkFzt0mWlScdbE514aHlj6H2AWpIKMVhWERZfMsoxvQxSIgcxxWddLZLo IfDS6JTBpbvRhe8NIPXV4rGjPowPUBEduTmmBMXHz92TgreLX7vs2J7hDTnKinlu J7xC3F/736vYLHEajbsdi1Ix19afsNKAs8uarSHHFdOOVM3Cdw4jw== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 93B6A102DE; Wed, 26 Sep 2018 17:48:14 -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: Wed, 26 Sep 2018 23:47:59 +0200 Message-Id: <20180926214759.1856-5-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926214759.1856-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20180926214759.1856-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 4/4] eal: simplify parameters of hotplug functions 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" All information about a device to probe can be grouped in a common string, which is what we usually call devargs. An application should not have to parse this string before calling the EAL probe function. And the syntax could evolve to be more complex and support matching multiple devices in one string. That's why the bus name and device name should be removed from rte_eal_hotplug_add(). Instead of changing this function, a simpler one is added and used in the old one, which may be deprecated later. When removing a device, we already know its rte_device handle which can be directly passed as parameter of rte_eal_hotplug_remove(). If the rte_device is not known, it can be retrieved with the devargs, by iterating in the device list (future RTE_DEV_FOREACH()). Similarly to the probing case, a new function is added and used in the old one, which may be deprecated later. The new function is used in failsafe, because the replacement is easy. Signed-off-by: Thomas Monjalon --- drivers/net/failsafe/failsafe_eal.c | 3 +- drivers/net/failsafe/failsafe_ether.c | 3 +- lib/librte_eal/common/eal_common_dev.c | 76 ++++++++++++++++--------- lib/librte_eal/common/include/rte_dev.h | 30 +++++++++- lib/librte_eal/rte_eal_version.map | 2 + 5 files changed, 80 insertions(+), 34 deletions(-) diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index ce1633f13..8a888b1ff 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev) int ret = 0; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { - sdev_ret = rte_eal_hotplug_remove(sdev->bus->name, - sdev->dev->name); + sdev_ret = rte_dev_remove(sdev->dev); if (sdev_ret) { ERROR("Failed to remove requested device %s (err: %d)", sdev->dev->name, sdev_ret); diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 5b5cb3b49..cd7b97e1f 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -265,8 +265,7 @@ fs_dev_remove(struct sub_device *sdev) sdev->state = DEV_PROBED; /* fallthrough */ case DEV_PROBED: - ret = rte_eal_hotplug_remove(sdev->bus->name, - sdev->dev->name); + ret = rte_dev_remove(sdev->dev); if (ret) { ERROR("Bus detach failed for sub_device %u", SUB_ID(sdev)); diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 43fdab395..85eb1569f 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -129,46 +129,57 @@ int rte_eal_dev_detach(struct rte_device *dev) int rte_eal_hotplug_add(const char *busname, const char *devname, - const char *devargs) + const char *drvargs) +{ + char *devargs = NULL; + int size, length = -1; + + do { /* 2 iterations: first is to know string length */ + size = length + 1; + length = snprintf(devargs, size, "%s:%s,%s", busname, devname, drvargs); + if (length >= size) + devargs = malloc(length + 1); + if (devargs == NULL) + return -ENOMEM; + } while (size == 0); + + return rte_dev_probe(devargs); +} + +int __rte_experimental +rte_dev_probe(const char *devargs) { - struct rte_bus *bus; struct rte_device *dev; struct rte_devargs *da; int ret; - bus = rte_bus_find_by_name(busname); - if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", busname); - return -ENOENT; - } - - if (bus->plug == NULL) { - RTE_LOG(ERR, EAL, "Function plug not supported by bus (%s)\n", - bus->name); - return -ENOTSUP; - } - da = calloc(1, sizeof(*da)); if (da == NULL) return -ENOMEM; - ret = rte_devargs_parsef(da, "%s:%s,%s", - busname, devname, devargs); + ret = rte_devargs_parse(da, devargs); if (ret) goto err_devarg; + if (da->bus->plug == NULL) { + RTE_LOG(ERR, EAL, "Function plug not supported by bus (%s)\n", + da->bus->name); + ret = -ENOTSUP; + goto err_devarg; + } + ret = rte_devargs_insert(da); if (ret) goto err_devarg; - ret = bus->scan(); + ret = da->bus->scan(); if (ret) goto err_devarg; - dev = bus->find_device(NULL, cmp_dev_name, devname); + dev = da->bus->find_device(NULL, cmp_dev_name, da->name); if (dev == NULL) { RTE_LOG(ERR, EAL, "Cannot find device (%s)\n", - devname); + da->name); ret = -ENODEV; goto err_devarg; } @@ -178,7 +189,7 @@ rte_eal_hotplug_add(const char *busname, const char *devname, return -EEXIST; } - ret = bus->plug(dev); + ret = da->bus->plug(dev); if (ret) { RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); @@ -197,9 +208,8 @@ rte_eal_hotplug_add(const char *busname, const char *devname, int rte_eal_hotplug_remove(const char *busname, const char *devname) { - struct rte_bus *bus; struct rte_device *dev; - int ret; + struct rte_bus *bus; bus = rte_bus_find_by_name(busname); if (bus == NULL) { @@ -207,23 +217,33 @@ rte_eal_hotplug_remove(const char *busname, const char *devname) return -ENOENT; } - if (bus->unplug == NULL) { - RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n", - bus->name); - return -ENOTSUP; - } - dev = bus->find_device(NULL, cmp_dev_name, devname); if (dev == NULL) { RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", devname); return -EINVAL; } + return rte_dev_remove(dev); +} + +int __rte_experimental +rte_dev_remove(struct rte_device *dev) +{ + struct rte_bus *bus; + int ret; + if (dev->driver == NULL) { RTE_LOG(ERR, EAL, "Device is already unplugged\n"); return -ENOENT; } + bus = dev->devargs->bus; + if (bus->unplug == NULL) { + RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n", + bus->name); + return -ENOTSUP; + } + ret = bus->unplug(dev); if (ret) RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 4f5282459..7a30362c0 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -196,13 +196,26 @@ int rte_eal_dev_detach(struct rte_device *dev); * @param devname * The device name. Based on this device name, eal will identify a driver * capable of handling it and pass it to the driver probing function. - * @param devargs + * @param drvargs * Device arguments to be passed to the driver. * @return * 0 on success, negative on error. */ int rte_eal_hotplug_add(const char *busname, const char *devname, - const char *devargs); + const char *drvargs); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Add matching devices. + * + * @param devargs + * Device arguments including bus, class and driver properties. + * @return + * 0 on success, negative on error. + */ +int __rte_experimental rte_dev_probe(const char *devargs); /** * Hotplug remove a given device from a specific bus. @@ -216,6 +229,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname, */ int rte_eal_hotplug_remove(const char *busname, const char *devname); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Remove one device. + * + * @param dev + * Data structure of the device to remove. + * @return + * 0 on success, negative on error. + */ +int __rte_experimental rte_dev_remove(struct rte_device *dev); + /** * Device comparison function. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 6bff37f4b..2ea7a870a 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -281,6 +281,8 @@ EXPERIMENTAL { rte_dev_event_monitor_stop; rte_dev_iterator_init; rte_dev_iterator_next; + rte_dev_probe; + rte_dev_remove; rte_devargs_add; rte_devargs_dump; rte_devargs_insert;