[dpdk-dev] [PATCH 1/2] ethdev: deduplicate functions to get link infos
Thomas Monjalon
thomas at monjalon.net
Wed Apr 8 14:49:20 CEST 2020
08/04/2020 07:21, Asaf Penso:
> From: Thomas Monjalon
> > +static int
> > +get_link_infos(uint16_t port_id, struct rte_eth_link *eth_link, int wait)
>
> I would recommend renaming to link_get_infos, to have the same naming
> convention as rte_eth_*link_get* and rte_eth_*link_get*_nowait
No strong opinion.
get_link_infos looks more natural english.
If others prefer to have a sort of consistency, fine.
> > +{
> > + struct rte_eth_dev *dev;
> > +
> > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> > + dev = &rte_eth_devices[port_id];
> > +
> > + if (dev->data->dev_conf.intr_conf.lsc &&
> > + dev->data->dev_started)
> > + rte_eth_linkstatus_get(dev, eth_link);
> > + else {
> > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
> > >link_update, -ENOTSUP);
> > + (*dev->dev_ops->link_update)(dev, wait);
> > + *eth_link = dev->data->dev_link;
> > + }
> > +
> > + return 0;
>
> Since it's a static function, I think it can return void,
No, it cannot return void because some errors may be returned
with the macros RTE_ETH_VALID_PORTID_OR_ERR_RET and
RTE_FUNC_PTR_OR_ERR_RET.
> and the calling functions can decide what to return,
> but it's a matter of taste.
>
> Do we want to check that the return value for eth_link
> is not NULL and return -1 in case it is?
eth_link must not be NULL. It is allocated by the caller.
More information about the dev
mailing list