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 2BAE9568A for ; Mon, 22 Oct 2018 14:31:41 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BA36E21D09; Mon, 22 Oct 2018 08:31:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 22 Oct 2018 08:31:40 -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=+jz8zlhO0A cXA2iTLQ/YKopTO8VuUfUhUWKxwvB1MFQ=; b=F/3EUaXjmzJe3zVLTZp/roxoff zJcwuipaXSbipFbCGHrfpzq+C7DFXnYZ2deq6uWoaM5OCxJmpZzqX4MZdmSS9iBq dOhBKTSOVkwFXQfJ7SXSLEWTWCIPFyKNNEwhSiD+vDrpTcASygisu8qQfi51WnYu R6kdcuHRi55E47dFA= 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= fm1; bh=+jz8zlhO0AcXA2iTLQ/YKopTO8VuUfUhUWKxwvB1MFQ=; b=bvSbfXgm 3Ya0ghKbGUA/MsWih2/Cofo8yTH6hH6p3rVOgWk+KFoej1HO/sx89phImYLfTfkQ ePE+OPYYpQ6dioTk/6UaAKVpTTK83INMyE0lt6EEc/NxKsLw8BVYz3bQVjt8CgPG W4v3ZN1dvHGWpUqWmcqPLz7hKBTESKutaUUWAGmN+ViMokyiO+7d32CW1oRo5cUs v+iuYuCnn4iwly+3V9/6eR5t2tEebLVIfKrT6tNxVKSV/5RzhTs5rIt1hzJNv17N bU3mP/e+govhy151N5AVSrJLrzuoVw4/WE6Njcip5Lvqt1lwx7ITKsHdCBq5TWqL ihLrj/xz34rdYg== 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 D5618E405D; Mon, 22 Oct 2018 08:31:38 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, wisamm@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com, bernard.iremonger@intel.com Date: Mon, 22 Oct 2018 14:31:08 +0200 Message-Id: <20181022123110.5733-6-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181022123110.5733-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> <20181022123110.5733-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 5/7] ethdev: remove deprecated attach/detach 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: , X-List-Received-Date: Mon, 22 Oct 2018 12:31:41 -0000 The hotplug attach/detach features are implemented in EAL layer. There is a new ethdev iterator to retrieve ports from ethdev layer. As announced earlier, the (buggy) ethdev functions are now removed. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko --- app/test-pmd/testpmd.c | 22 +++- doc/guides/prog_guide/index.rst | 1 - .../prog_guide/port_hotplug_framework.rst | 106 ------------------ doc/guides/rel_notes/deprecation.rst | 7 -- doc/guides/rel_notes/release_18_11.rst | 6 + drivers/net/virtio/virtio_user_ethdev.c | 1 - lib/librte_ethdev/rte_ethdev.c | 81 ------------- lib/librte_ethdev/rte_ethdev.h | 31 ----- lib/librte_ethdev/rte_ethdev_version.map | 2 - 9 files changed, 22 insertions(+), 235 deletions(-) delete mode 100644 doc/guides/prog_guide/port_hotplug_framework.rst diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index eea6df0fa..14647fa19 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -481,6 +481,7 @@ struct nvgre_encap_conf nvgre_encap_conf = { }; /* Forward function declarations */ +static void setup_attached_port(portid_t pi); static void map_port_queue_stats_mapping_registers(portid_t pi, struct rte_port *port); static void check_all_ports_link_status(uint32_t port_mask); @@ -2308,7 +2309,7 @@ void attach_port(char *identifier) { portid_t pi = 0; - unsigned int socket_id; + struct rte_dev_iterator iterator; printf("Attaching a new port...\n"); @@ -2317,8 +2318,19 @@ attach_port(char *identifier) return; } - if (rte_eth_dev_attach(identifier, &pi)) + if (rte_dev_probe(identifier) != 0) { + TESTPMD_LOG(ERR, "Failed to attach port %s\n", identifier); return; + } + + RTE_ETH_FOREACH_MATCHING_DEV(pi, identifier, &iterator) + setup_attached_port(pi); +} + +static void +setup_attached_port(portid_t pi) +{ + unsigned int socket_id; socket_id = (unsigned)rte_eth_dev_socket_id(pi); /* if socket_id is invalid, set to the first available socket. */ @@ -2341,9 +2353,7 @@ attach_port(char *identifier) void detach_port(portid_t port_id) { - char name[RTE_ETH_NAME_MAX_LEN]; - - printf("Detaching a port...\n"); + printf("Removing a device...\n"); if (ports[port_id].port_status != RTE_PORT_CLOSED) { if (ports[port_id].port_status != RTE_PORT_STOPPED) { @@ -2355,7 +2365,7 @@ detach_port(portid_t port_id) port_flow_flush(port_id); } - if (rte_eth_dev_detach(port_id, name)) { + if (rte_dev_remove(rte_eth_devices[port_id].device) != 0) { TESTPMD_LOG(ERR, "Failed to detach port %u\n", port_id); return; } diff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst index c81d9c54f..2086e2442 100644 --- a/doc/guides/prog_guide/index.rst +++ b/doc/guides/prog_guide/index.rst @@ -53,7 +53,6 @@ Programmer's Guide packet_framework vhost_lib metrics_lib - port_hotplug_framework bpf_lib source_org dev_kit_build_system diff --git a/doc/guides/prog_guide/port_hotplug_framework.rst b/doc/guides/prog_guide/port_hotplug_framework.rst deleted file mode 100644 index fb0efc18f..000000000 --- a/doc/guides/prog_guide/port_hotplug_framework.rst +++ /dev/null @@ -1,106 +0,0 @@ -.. BSD LICENSE - Copyright(c) 2015 IGEL Co.,Ltd. All rights reserved. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of IGEL Co.,Ltd. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Port Hotplug Framework -====================== - -The Port Hotplug Framework provides DPDK applications with the ability to -attach and detach ports at runtime. Because the framework depends on PMD -implementation, the ports that PMDs cannot handle are out of scope of this -framework. Furthermore, after detaching a port from a DPDK application, the -framework doesn't provide a way for removing the devices from the system. -For the ports backed by a physical NIC, the kernel will need to support PCI -Hotplug feature. - -Overview --------- - -The basic requirements of the Port Hotplug Framework are: - -* DPDK applications that use the Port Hotplug Framework must manage their - own ports. - - The Port Hotplug Framework is implemented to allow DPDK applications to - manage ports. For example, when DPDK applications call the port attach - function, the attached port number is returned. DPDK applications can - also detach the port by port number. - -* Kernel support is needed for attaching or detaching physical device - ports. - - To attach new physical device ports, the device will be recognized by - userspace driver I/O framework in kernel at first. Then DPDK - applications can call the Port Hotplug functions to attach the ports. - For detaching, steps are vice versa. - -* Before detaching, they must be stopped and closed. - - DPDK applications must call "rte_eth_dev_stop()" and - "rte_eth_dev_close()" APIs before detaching ports. These functions will - start finalization sequence of the PMDs. - -* The framework doesn't affect legacy DPDK applications behavior. - - If the Port Hotplug functions aren't called, all legacy DPDK apps can - still work without modifications. - -Port Hotplug API overview -------------------------- - -* Attaching a port - - "rte_eth_dev_attach()" API attaches a port to DPDK application, and - returns the attached port number. Before calling the API, the device - should be recognized by an userspace driver I/O framework. The API - receives a pci address like "0000:01:00.0" or a virtual device name - like "net_pcap0,iface=eth0". In the case of virtual device name, the - format is the same as the general "--vdev" option of DPDK. - -* Detaching a port - - "rte_eth_dev_detach()" API detaches a port from DPDK application, and - returns a pci address of the detached device or a virtual device name - of the device. - -Reference ---------- - - "testpmd" supports the Port Hotplug Framework. - -Limitations ------------ - -* The Port Hotplug APIs are not thread safe. - -* The framework can only be enabled with Linux. BSD is not supported. - -* Not all PMDs support detaching feature. - The underlying bus must support hot-unplug. If not supported, - the function ``rte_eth_dev_detach()`` will return negative ENOTSUP. diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 9f825f09e..6b51c9d28 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -49,13 +49,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* ethdev: In v18.11 ``rte_eth_dev_attach()`` and ``rte_eth_dev_detach()`` - will be removed. - Hotplug functions ``rte_eal_hotplug_add()`` and ``rte_eal_hotplug_remove()`` - should be used instread. - Function ``rte_eth_dev_get_port_by_name()`` may be used to find - identifier of the added port. - * eal: In v18.11 ``rte_eal_dev_attach()`` and ``rte_eal_dev_detach()`` will be removed. Hotplug functions ``rte_eal_hotplug_add()`` and ``rte_eal_hotplug_remove()`` diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index b1028b493..e7e676a05 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -242,6 +242,12 @@ API Changes functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. +* ethdev: The deprecated functions attach/detach were removed in 18.11. + ``rte_eth_dev_attach`` can be replaced by ``RTE_ETH_FOREACH_MATCHING_DEV`` + and ``rte_dev_probe`` or ``rte_eal_hotplug_add``. + ``rte_eth_dev_detach`` can be replaced by + ``rte_dev_remove`` or ``rte_eal_hotplug_remove``. + * ethdev: A call to ``rte_eth_dev_release_port()`` has been added in ``rte_eth_dev_close()``. As a consequence, a closed port is freed and seen as invalid because of its state ``RTE_ETH_DEV_UNUSED``. diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 420364b7a..b51cbc85b 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -635,7 +635,6 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) return ret; } -/** Called by rte_eth_dev_detach() */ static int virtio_user_pmd_remove(struct rte_vdev_device *vdev) { diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7ed71744c..2b218d4a2 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -800,87 +800,6 @@ eth_err(uint16_t port_id, int ret) return ret; } -/* attach the new device, then store port_id of the device */ -int -rte_eth_dev_attach(const char *devargs, uint16_t *port_id) -{ - int current = rte_eth_dev_count_total(); - struct rte_devargs da; - int ret = -1; - - memset(&da, 0, sizeof(da)); - - if ((devargs == NULL) || (port_id == NULL)) { - ret = -EINVAL; - goto err; - } - - /* parse devargs */ - if (rte_devargs_parse(&da, devargs)) - goto err; - - 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()) { - RTE_ETHDEV_LOG(ERR, "No port found for device (%s)\n", da.name); - ret = -1; - goto err; - } - - /* if nothing happened, there is a bug here, since some driver told us - * it did attach a device, but did not create a port. - * FIXME: race condition in case of plug-out of another device - */ - if (current == rte_eth_dev_count_total()) { - ret = -1; - goto err; - } - - *port_id = eth_dev_last_created_port; - ret = 0; - -err: - 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_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); - - dev_flags = rte_eth_devices[port_id].data->dev_flags; - if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { - RTE_ETHDEV_LOG(ERR, - "Port %"PRIu16" is bonded, cannot detach\n", port_id); - return -ENOTSUP; - } - - dev = rte_eth_devices[port_id].device; - if (dev == NULL) - return -EINVAL; - - bus = rte_bus_find_by_device(dev); - if (bus == NULL) - return -ENOENT; - - ret = rte_eal_hotplug_remove(bus->name, dev->name); - if (ret < 0) - return ret; - - rte_eth_dev_release_port(&rte_eth_devices[port_id]); - return 0; -} - static int rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index e4ee45ef5..c0392bec2 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1504,37 +1504,6 @@ uint16_t rte_eth_dev_count_avail(void); */ uint16_t __rte_experimental rte_eth_dev_count_total(void); -/** - * Attach a new Ethernet device specified by arguments. - * - * @param devargs - * A pointer to a strings array describing the new device - * to be attached. The strings should be a pci address like - * '0000:01:00.0' or virtual device name like 'net_pcap0'. - * @param port_id - * A pointer to a port identifier actually attached. - * @return - * 0 on success and port_id is filled, negative on error - */ -__rte_deprecated -int rte_eth_dev_attach(const char *devargs, uint16_t *port_id); - -/** - * Detach a Ethernet device specified by port identifier. - * This function must be called when the device is in the - * closed state. - * - * @param port_id - * The port identifier of the device to detach. - * @param devname - * A pointer to a buffer that will be filled with the device name. - * This buffer must be at least RTE_DEV_NAME_MAX_LEN long. - * @return - * 0 on success and devname is filled, negative on error - */ -__rte_deprecated -int rte_eth_dev_detach(uint16_t port_id, char *devname); - /** * Convert a numerical speed in Mbps to a bitmap flag that can be used in * the bitmap link_speeds of the struct rte_eth_conf diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 399380ad3..8038d4e5b 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -8,14 +8,12 @@ DPDK_2.2 { rte_eth_allmulticast_get; rte_eth_dev_allocate; rte_eth_dev_allocated; - rte_eth_dev_attach; rte_eth_dev_callback_register; rte_eth_dev_callback_unregister; rte_eth_dev_close; rte_eth_dev_configure; rte_eth_dev_count; rte_eth_dev_default_mac_addr_set; - rte_eth_dev_detach; rte_eth_dev_filter_supported; rte_eth_dev_flow_ctrl_get; rte_eth_dev_flow_ctrl_set; -- 2.19.0