From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 2E65FA49 for ; Fri, 21 Sep 2018 09:20:22 +0200 (CEST) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id w8L7KJMo007105; Fri, 21 Sep 2018 16:20:19 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id w8L7KJa6011480; Fri, 21 Sep 2018 16:20:19 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id SAA11479; Fri, 21 Sep 2018 16:20:19 +0900 Received: from imss06.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by ccmail04.silk.ntt-tx.co.jp (unknown) with ESMTP id w8L7KJSQ016673; Fri, 21 Sep 2018 16:20:19 +0900 Received: from imss06.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss06.silk.ntt-tx.co.jp (unknown) with ESMTP id w8L7KIYU003531; Fri, 21 Sep 2018 16:20:18 +0900 Received: from ccmail04 (smtp03.silk.ntt-tx.co.jp [10.107.0.135]) by imss06.silk.ntt-tx.co.jp (unknown) with SMTP id w8L7KIWE003528; Fri, 21 Sep 2018 16:20:18 +0900 Date: Fri, 21 Sep 2018 16:19:54 +0900 From: Hideyuki Yamashita In-Reply-To: <69884841.TAV26K5Juc@xps> References: <20180920090919.qigxfgy4qaw6p5om@bidouze.vm.6wind.com> <69884841.TAV26K5Juc@xps> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.74 [ja] X-CCMail7: CC-Mail-V7.0.2-Client-Relayed Message-Id: <201809210720.w8L7JtuZ016319@ccmail04.silk.ntt-tx.co.jp> X-TM-AS-MML: No X-CC-Mail-RelayStamp: CC-Mail-V5.14-Server To: Thomas Monjalon Cc: dev@dpdk.org, Gaetan Rivet Subject: Re: [dpdk-dev] How to replace rte_eth_dev_attach with rte_eal_hotplug_add 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: Fri, 21 Sep 2018 07:20:23 -0000 Dear Gaetan and Thomas, Thanks for your answer. Please see inline. > 20/09/2018 11:09, Ga$BuU(Ban Rivet: > > On Thu, Sep 20, 2018 at 05:46:37PM +0900, Hideyuki Yamashita wrote: > > > Hello, > > > > > > From dpdk 18.08 release rte_eth_dev_attach and > > > rte_eth_dev_detach becom deprecated API and > > > it is recommended to replace with rte_eal_hotplug_add > > > and rte_eal_hotplug_remove. > > > > > > My program uses above mentioned deprecated APIs > > > and have to replace those. > > > Note that my program uses attach to attach vhost, pcap pmd. > > > > > > My question is whether it is correct to replace those as following: > > > find rte_eth_dev_attach function in rte_ethdev.c and > > > migrate those content into my program. > > > > > > e.g. > > > lib/librte_ethdev/rte_ethdev.c line 643-686 for attach > > > lib/librte_ethdev/rte_ethdev.c line 690-720 for detach > > > > > > Your advice/guidance are much appreciated. > > > Thanks! > > > > Hello Hideyuki, > > > > You could use this code for guidance, while leaving the ethdev > > specificities such as verifying the eth_dev_count_total(). The hotplug > > function would already return an error if the PMD was not able to create > > the necessary devices. > > > > The main issue might be to find the port_id of your new port. > > You won't be able to use eth_dev_last_created_port, so you would have to > > iterate over the ethdev using RTE_ETH_FOREACH_DEV and find the one > > matching your parameters (you might for example match the rte_device > > name with the name you used in hotplug_add, as there is no standard > > naming scheme at the ethdev level). First of all, thank for your answering to my question. But I have questions. (Sorry, I have poor knowledge about dpdk and have many basic questions) Q1. Why eth_dev_last_created_port can not be used? When I look into rte_eth_dev_atthach in 18.08, it calls *port_id = eth_dev_last_created_port; at the end of the function. Q2. Is it possible to use rte_eth_dev_get_port_by name instead of calling RTE_ETH_FOREACH_DEV or using eth_dev_last_created_port? Q3. If answer to Q2 is no, then how can I get device name from each device? For example, rte_eth_dev_info_get takes port_id as its argument.But what I want to know is the port id of the specified device name. > It is recommended to register a callback to receive the notifications > of new ethdev ports. > So it may be a change of programming style: sync vs async. Thanks for your advice. In general, I agree. But what is the example of notification that program can receive after device hotplugged? Device unplugged notification like specified in rte_eth_event_type? If there are code in example, it is highly appreciated. > > An possible issue with the deprecation planned for those two functions is > > that the hotplug API is also meant to evolve [1] this release (not in a big > > way however, it would mostly simplify your usage of it). > > > > [1]: https://mails.dpdk.org/archives/dev/2018-September/111142.html > > I will probably not change the existing functions. > A v2 will be sent soon, with new simple functions. > > > BR, Hideyuki Yamashita NTT TechnoCross