[dpdk-dev] [PATCH v1] ethdev: add rte_device to port_id function

Gaëtan Rivet grive at u256.net
Sun Apr 19 21:36:35 CEST 2020


On 17/04/20 13:44 -0700, Stephen Hemminger wrote:
> On Fri, 17 Apr 2020 18:48:37 +0200
> Gaetan Rivet <grive at u256.net> wrote:
> 
> > +/**
> > + * Find the owned ethdev port id of an `rte_device`.
> > + *
> > + * @param dev
> > + *   An `rte_device`.
> > + * @param owner
> > + *   An owner id. Use `RTE_ETH_DEV_NO_OWNER` for ownerless ports.
> > + *
> > + * @return
> > + *   The port id of an `rte_device` if it is owned by `owner`.
> > + *   `RTE_MAX_ETHPORTS` otherwise.
> > + */
> > +__rte_experimental
> > +uint16_t rte_eth_port_from_dev_owned_by(const struct rte_device *dev,
> > +					const uint64_t owner);
> > +
> 
> Ok, but why introduce API with no users?
> Also a device could in theory be owned multiple times by the same owner.
> For example if two NIC's from same vendor were used in bonding.

I'm not sure what you mean by a device being owned multiple times by the
same owner. However if that's what you are referencing, the issue here
is of course the multiple ports spawning from a single device.

I forgot about this edge-case, so this API is incorrect. This also means
that my "fix" for bonding is incorrect.

The current API, RTE_ETH_FOREACH_DEV_OF(), does not offer an owner-aware
version. If the ownership model is bound to continue as it is, it should
probably offer a variant. The problem is that port iterators in ethdev
are already too many, I don't know how a user could make sense of it.

Thanks for the comment Stephen, this patch should be dropped.
-- 
Gaëtan


More information about the dev mailing list