[dpdk-dev] How to replace rte_eth_dev_attach with rte_eal_hotplug_add

Thomas Monjalon thomas at monjalon.net
Thu Sep 20 15:02:38 CEST 2018


20/09/2018 11:09, Gaëtan 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).

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.

> 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.





More information about the dev mailing list