From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 2FE591B19 for ; Tue, 24 Apr 2018 00:41:48 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id v60-v6so45433651wrc.7 for ; Mon, 23 Apr 2018 15:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=JBOsrqQYjiHGPbg8taxRcAw+VJxCkQgEC5OnR+0+vIc=; b=JdObKjh21yRM4ytSwl838Tp1vUAYZ2Lxge83qZT5OSGFHB35NoJRNkOz07lEf8Rc5u 9Xo3Nltp9RQEkPjZ25GuEklGRn8UI9hluxbArD+lIdfyjbXfWC9JS7+tvgZFbFPYaooA Pz7fQC3JYGgirVWbUv9b5s693hByBbYqswijHs7H0PUmcD9j4ubvpxCFRUmyP5dXIrx9 HarSNxdWNvt7dx2nMUefCl3URQGATGbUIIzNPoBXwOE52Ie5x1g/sD5P6w5jfNoIWKSV OHnHGloYzzm+n267fRazDiYU9MSSLvPmlgKBcD75DcnizfUQ1xEl5m137mEPR5pv2dCh 3U5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=JBOsrqQYjiHGPbg8taxRcAw+VJxCkQgEC5OnR+0+vIc=; b=hPhMe22gWanKYJDzWU09bedM7MIVxh4PtF+gTP80rEzJEL07XxGUAp3Yg8UtZM9eoB HkzrlBT8k5gv7+KIzK9W79xvaUhCgP/Go7LrC/sfykaQkKiSZg7cLSUZdHaSYvYv/o1Z sK3HXITrHSooGBjxLyy+MqBINFEb62RBAZ0xKOsMaVq+GrF5piM19BST+torZAvhXfZX DDaLxROdRmgj6s2ta8rZV0dmd277XJCmnocBO1HuUcYAYm13zuFyyFaDewGopr6ekOQu mqBwy5c78J1gFfahA8M2ZMaCTZ+Bi8W7i/WnKdReyFZ1wV0JxFnVZdFRd4pXo5f9kCKX n4IQ== X-Gm-Message-State: ALQs6tAy0dqXBxIxPk0hu4rO8PGvSqqwLcba/d8jya4mIZfJaRNxMBbP s1w8JE1HYp88yrosx3KIXqCJXeWR X-Google-Smtp-Source: AIpwx4/7Jy8YChj8UOyWvJNNahnx14ley3Yphb+uusQlZdBSt9QSquKQ6/M6aWeOWy91KG/+dm1bdg== X-Received: by 10.28.10.83 with SMTP id 80mr11179311wmk.70.1524523307933; Mon, 23 Apr 2018 15:41:47 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x189sm1590705wmg.0.2018.04.23.15.41.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 15:41:46 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 24 Apr 2018 00:41:10 +0200 Message-Id: <2e37818bc96b38ee90a9821b3f5a7fc53f0faf51.1524522516.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 10/10] devargs: rename legacy 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: , X-List-Received-Date: Mon, 23 Apr 2018 22:41:50 -0000 This previous symbols were deprecated for two releases. They are now marked as such and cannot be used anymore. They are replaced by ones respecting the new namespace that are marked experimental. As a result, eth_dev attach and detach is slightly reworked to follow the changes. Signed-off-by: Gaetan Rivet --- app/test-pmd/cmdline.c | 2 +- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- examples/bond/Makefile | 1 + examples/bond/main.c | 2 +- lib/librte_eal/common/eal_common_devargs.c | 9 +++-- lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/common/include/rte_devargs.h | 54 +++++++++++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 3 ++ lib/librte_ether/rte_ethdev.c | 44 +++++++++++------------ test/test/commands.c | 2 +- 10 files changed, 89 insertions(+), 32 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0b442c3a6..18470c6fc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -8754,7 +8754,7 @@ static void cmd_dump_parsed(void *parsed_result, else if (!strcmp(res->dump, "dump_mempool")) rte_mempool_list_dump(stdout); else if (!strcmp(res->dump, "dump_devargs")) - rte_eal_devargs_dump(stdout); + rte_devargs_dump(stdout); else if (!strcmp(res->dump, "dump_log_types")) rte_log_dump(stdout); } diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index 8b85711d4..f902dbe27 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -803,7 +803,7 @@ vdev_netvsc_scan_callback(__rte_unused void *arg) vdev_netvsc_cmp_rte_device, VDEV_NETVSC_DRIVER_NAME); if (dev) return; - if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME)) + if (rte_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME)) DRV_LOG(ERR, "unable to add netvsc devargs."); } diff --git a/examples/bond/Makefile b/examples/bond/Makefile index e7afce358..6b0324a42 100644 --- a/examples/bond/Makefile +++ b/examples/bond/Makefile @@ -62,6 +62,7 @@ endif CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 +CFLAGS += -DALLOW_EXPERIMENTAL_API ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) LDLIBS += -lrte_pmd_bond diff --git a/examples/bond/main.c b/examples/bond/main.c index d8edc642b..65e0edd25 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -742,7 +742,7 @@ main(int argc, char *argv[]) /* init EAL */ ret = rte_eal_init(argc, argv); - rte_eal_devargs_dump(stdout); + rte_devargs_dump(stdout); if (ret < 0) rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); argc -= ret; diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 24d0f6f44..b0434158b 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -137,8 +137,9 @@ rte_devargs_insert(struct rte_devargs *da) } /* store a whitelist parameter for later parsing */ +__rte_experimental int -rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) +rte_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; struct rte_bus *bus = NULL; @@ -192,8 +193,9 @@ rte_devargs_remove(const char *busname, const char *devname) } /* count the number of devices of a specified type */ +__rte_experimental unsigned int -rte_eal_devargs_type_count(enum rte_devtype devtype) +rte_devargs_type_count(enum rte_devtype devtype) { struct rte_devargs *devargs; unsigned int count = 0; @@ -207,8 +209,9 @@ rte_eal_devargs_type_count(enum rte_devtype devtype) } /* dump the user devices on the console */ +__rte_experimental void -rte_eal_devargs_dump(FILE *f) +rte_devargs_dump(FILE *f) { struct rte_devargs *devargs; diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 40c5b26f3..e1a1a3c56 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -153,7 +153,7 @@ eal_option_device_parse(void) TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) { if (ret == 0) { - ret = rte_eal_devargs_add(devopt->type, devopt->arg); + ret = rte_devargs_add(devopt->type, devopt->arg); if (ret) RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n", devopt->arg); diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 07a4701b2..3ba1f2084 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -60,6 +60,7 @@ struct rte_devargs { }; /** + * @deprecated * Parse a devargs string. * * For PCI devices, the format of arguments string is "PCI_ADDR" or @@ -84,6 +85,7 @@ struct rte_devargs { * - 0 on success * - A negative value on error */ +__rte_deprecated int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs); @@ -146,6 +148,32 @@ rte_devargs_insert(struct rte_devargs *da); * - 0 on success * - A negative value on error */ +__rte_experimental +int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str); + +/** + * @deprecated + * Add a device to the user device list + * + * The format is + * + * bus:device_identifier,arg1=val1,arg2=val2 + * + * Examples: + * + * pci:0000:05.00.0,arg=val + * vdev:net_ring0 + * + * @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); /** @@ -177,6 +205,21 @@ int rte_devargs_remove(const char *busname, * @return * The number of devices. */ +__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); @@ -186,6 +229,17 @@ rte_eal_devargs_type_count(enum rte_devtype devtype); * @param f * A pointer to a file for output */ +__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); /** diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 526b0d95c..d744312ec 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -217,10 +217,13 @@ EXPERIMENTAL { rte_dev_event_monitor_start; rte_dev_event_monitor_stop; rte_eal_cleanup; + rte_devargs_add; + rte_devargs_dump; rte_devargs_insert; rte_devargs_next; rte_devargs_parse; rte_devargs_remove; + rte_devargs_type_count; rte_eal_hotplug_add; rte_eal_hotplug_remove; rte_eal_mbuf_user_pool_ops; diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 7821a8883..600866de7 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -618,27 +618,26 @@ eth_err(uint16_t port_id, int ret) int rte_eth_dev_attach(const char *devargs, uint16_t *port_id) { - int ret = -1; int current = rte_eth_dev_count_total(); - char *name = NULL; - char *args = NULL; + struct rte_devargs da = {0}; + int ret = -1; if ((devargs == NULL) || (port_id == NULL)) { ret = -EINVAL; goto err; } - /* parse devargs, then retrieve device name and args */ - if (rte_eal_parse_devargs_str(devargs, &name, &args)) + /* parse devargs */ + if (rte_devargs_parse(&da, "%s", devargs)) goto err; - ret = rte_eal_dev_attach(name, args); + ret = rte_eal_hotplug_add(da.bus->name, da.name, da.args); if (ret < 0) goto err; /* no point looking at the port count if no port exists */ if (!rte_eth_dev_count_total()) { - ethdev_log(ERR, "No port found for device (%s)", name); + ethdev_log(ERR, "No port found for device (%s)", da.name); ret = -1; goto err; } @@ -656,45 +655,42 @@ rte_eth_dev_attach(const char *devargs, uint16_t *port_id) ret = 0; err: - free(name); - free(args); + free(da.args); return ret; } /* detach the device, then store the name of the device */ int -rte_eth_dev_detach(uint16_t port_id, char *name) +rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused) { + struct rte_device *dev; + struct rte_bus *bus; uint32_t dev_flags; int ret = -1; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); - if (name == NULL) { - ret = -EINVAL; - goto err; - } - dev_flags = rte_eth_devices[port_id].data->dev_flags; if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { ethdev_log(ERR, "Port %" PRIu16 " is bonded, cannot detach", port_id); - ret = -ENOTSUP; - goto err; + return -ENOTSUP; } - snprintf(name, sizeof(rte_eth_devices[port_id].data->name), - "%s", rte_eth_devices[port_id].data->name); + dev = rte_eth_devices[port_id].device; + if (dev == NULL) + return -EINVAL; - ret = rte_eal_dev_detach(rte_eth_devices[port_id].device); + bus = rte_bus_find_by_device(dev); + if (bus == NULL) + return -ENOENT; + + ret = rte_eal_hotplug_remove(bus->name, dev->name); if (ret < 0) - goto err; + return ret; rte_eth_dev_release_port(&rte_eth_devices[port_id]); return 0; - -err: - return ret; } static int diff --git a/test/test/commands.c b/test/test/commands.c index 6bfdc0272..94fbc310e 100644 --- a/test/test/commands.c +++ b/test/test/commands.c @@ -132,7 +132,7 @@ static void cmd_dump_parsed(void *parsed_result, else if (!strcmp(res->dump, "dump_mempool")) rte_mempool_list_dump(stdout); else if (!strcmp(res->dump, "dump_devargs")) - rte_eal_devargs_dump(stdout); + rte_devargs_dump(stdout); else if (!strcmp(res->dump, "dump_log_types")) rte_log_dump(stdout); else if (!strcmp(res->dump, "dump_malloc_stats")) -- 2.11.0