[dpdk-dev] [PATCH v3 1/4] ethdev: simplify port state comparisons
Slava Ovsiienko
viacheslavo at mellanox.com
Wed Apr 3 17:03:21 CEST 2019
> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Thomas Monjalon
> Sent: Monday, April 1, 2019 5:27
> To: gaetan.rivet at 6wind.com; Ferruh Yigit <ferruh.yigit at intel.com>; Andrew
> Rybchenko <arybchenko at solarflare.com>
> Cc: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: simplify port state comparisons
>
> There are three states for an ethdev port.
> Checking that the port is unused looks simpler than checking it is neither
> attached nor removed.
>
> Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
> Reviewed-by: Andrew Rybchenko <arybchenko at solarflare.com>
Tested-by: Viacheslav Ovsiienko <mellanox.com>
> ---
> lib/librte_ethdev/rte_ethdev.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 10bdfb37e..33cffc498 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -330,8 +330,7 @@ uint16_t
> rte_eth_find_next(uint16_t port_id)
> {
> while (port_id < RTE_MAX_ETHPORTS &&
> - rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED &&
> - rte_eth_devices[port_id].state != RTE_ETH_DEV_REMOVED)
> + rte_eth_devices[port_id].state ==
> RTE_ETH_DEV_UNUSED)
> port_id++;
>
> if (port_id >= RTE_MAX_ETHPORTS)
> @@ -567,8 +566,7 @@ uint64_t
> rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id) {
> while (port_id < RTE_MAX_ETHPORTS &&
> - ((rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED &&
> - rte_eth_devices[port_id].state != RTE_ETH_DEV_REMOVED) ||
> + (rte_eth_devices[port_id].state == RTE_ETH_DEV_UNUSED ||
> rte_eth_devices[port_id].data->owner.id != owner_id))
> port_id++;
>
> --
> 2.21.0
More information about the dev
mailing list