[dpdk-dev] [PATCH v5 3/3] ethdev: allow close function to return an error
Thomas Monjalon
thomas at monjalon.net
Tue Oct 13 12:43:59 CEST 2020
13/10/2020 12:41, Andrew Rybchenko:
> On 10/13/20 1:06 PM, Thomas Monjalon wrote:
> > The API function rte_eth_dev_close() was returning void.
> > The return type is changed to int for notifying of errors.
> >
> > If an error happens during a close operation,
> > the status of the port is undefined,
> > a maximum of resources having been freed.
> >
> > Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
> > Reviewed-by: Liron Himi <lironh at marvell.com>
> > Acked-by: Stephen Hemminger <stephen at networkplumber.org>
>
> Acked-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
>
> [snip]
>
> > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> > index 73c3d6f7fe..ad12d4f07a 100644
> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> > @@ -1716,19 +1716,25 @@ rte_eth_dev_set_link_down(uint16_t port_id)
> > return eth_err(port_id, (*dev->dev_ops->dev_set_link_down)(dev));
> > }
> >
> > -void
> > +int
> > rte_eth_dev_close(uint16_t port_id)
> > {
> > struct rte_eth_dev *dev;
> > + int firsterr, binerr;
> > + int *lasterr = &firsterr;
> >
> > - RTE_ETH_VALID_PORTID_OR_RET(port_id);
> > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> > dev = &rte_eth_devices[port_id];
> >
> > - RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
> > - (*dev->dev_ops->dev_close)(dev);
> > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP);
> > + *lasterr = (*dev->dev_ops->dev_close)(dev);
> > + if (*lasterr != 0)
> > + lasterr = &binerr;
> >
> > rte_ethdev_trace_close(port_id);
> > - rte_eth_dev_release_port(dev);
> > + *lasterr = rte_eth_dev_release_port(dev);
> > +
> > + return firsterr;
>
> Shouldn't eth_err() be used here?
Yes you're right (again)
Will do a v6, thanks for the review.
More information about the dev
mailing list