On 10/5/2020 6:08 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 <tho...@monjalon.net>
Reviewed-by: Liron Himi <lir...@marvell.com>
Acked-by: Stephen Hemminger <step...@networkplumber.org>
<...>
-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, -EINVAL);
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;
}
This may be personal taste but above error handling looks like unnecessary
complex, what do you think something like below:
close_err = (*dev->dev_ops->dev_close)(dev);
release_err = rte_eth_dev_release_port(dev);
return close_err ? close_err : release_err;