27/02/2019 11:51, Thomas Monjalon: > 27/02/2019 11:07, Gaëtan Rivet: > > On Wed, Feb 20, 2019 at 11:10:49PM +0100, Thomas Monjalon wrote: > > > +uint16_t __rte_experimental > > > +rte_eth_find_next_of(uint16_t port_id, const struct rte_device *parent) > > > +{ > > > + while (port_id < RTE_MAX_ETHPORTS && > > > + rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED && > > > + rte_eth_devices[port_id].device != parent) > > > + port_id++; > > > > Why not call rte_eth_find_next directly from this function, and > > add your specific test on top of it? > > > > Something like: > > > > while (port_id < RTE_MAX_ETHPORTS && > > rte_eth_devices[port_id].device != parent) > > port_id = rte_eth_find_next(port_id + 1); > > > > this way you won't have to rewrite the test on the device state. Having the > > logic expressed in several places would make reworking the device states more > > complicated than necessary if it were to happen (just as you did when switching > > the test from !(ATTACHED || REMOVED) to (UNUSED). > > About the intent, you are right. > About the solution, it seems buggy. We can try to find another way > of coding this loop by using rte_eth_find_next() > and adding the parent condition. Your proposal is correct if adding a first call before the loop: port_id = rte_eth_find_next(port_id);