[dpdk-dev] [PATCH v3 29/29] ethdev: allow close function to return an error

Andrew Rybchenko arybchenko at solarflare.com
Tue Sep 29 13:05:01 CEST 2020


On 9/29/20 2:14 AM, 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>

[snip]

> diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> index d07b4eeb47..1a61bd671a 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -135,7 +135,6 @@ Deprecation Notices
>    invalid port ID, unsupported operation, failed operation):
>  
>    - ``rte_eth_dev_stop``
> -  - ``rte_eth_dev_close``

Many thanks for continuing my unfinished job.

>  
>  * ethdev: New offload flags ``DEV_RX_OFFLOAD_FLOW_MARK`` will be added in 19.11.
>    This will allow application to enable or disable PMDs from updating

[snip]

> diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
> index 607771149a..13d4b6af6b 100644
> --- a/drivers/net/mvneta/mvneta_ethdev.c
> +++ b/drivers/net/mvneta/mvneta_ethdev.c
> @@ -964,14 +964,15 @@ static int
>  rte_pmd_mvneta_remove(struct rte_vdev_device *vdev)
>  {
>  	uint16_t port_id;
> +	int ret = 0;
>  
>  	RTE_ETH_FOREACH_DEV(port_id) {
>  		if (rte_eth_devices[port_id].device != &vdev->device)
>  			continue;
> -		rte_eth_dev_close(port_id);
> +		ret = rte_eth_dev_close(port_id);

I guess |= should be used here as well (similar as above).

>  	}
>  
> -	return 0;
> +	return ret == 0 ? 0 : -EIO;
>  }
>  
>  static struct rte_vdev_driver pmd_mvneta_drv = {
> diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
> index a230a96840..acc8c70a95 100644
> --- a/drivers/net/mvpp2/mrvl_ethdev.c
> +++ b/drivers/net/mvpp2/mrvl_ethdev.c
> @@ -3022,14 +3022,15 @@ static int
>  rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
>  {
>  	uint16_t port_id;
> +	int ret = 0;
>  
>  	RTE_ETH_FOREACH_DEV(port_id) {
>  		if (rte_eth_devices[port_id].device != &vdev->device)
>  			continue;
> -		rte_eth_dev_close(port_id);
> +		ret = rte_eth_dev_close(port_id);

I guess |= should be used here as well (similar as above).

>  	}
>  
> -	return 0;
> +	return ret == 0 ? 0 : -EIO;
>  }
>  
>  static struct rte_vdev_driver pmd_mrvl_drv = {

[snip]

> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index e68943b461..1459ac1ad5 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -1704,19 +1704,22 @@ 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 ret;
>  
> -	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);
> +	ret = (*dev->dev_ops->dev_close)(dev);
>  
>  	rte_ethdev_trace_close(port_id);
> -	rte_eth_dev_release_port(dev);
> +	ret = rte_eth_dev_release_port(dev);

It does not look good that it overwrites close return status.

> +
> +	return ret;
>  }
>  
>  int

[snip]



More information about the dev mailing list