[PATCH] net/netvsc: use rte_eth_dev_set_mtu to set VF MTU

Ferruh Yigit ferruh.yigit at amd.com
Fri Jul 19 22:39:04 CEST 2024


On 7/18/2024 8:35 PM, longli at linuxonhyperv.com wrote:
> From: Stephen Hemminger <stephen at networkplumber.org>
> 
> The current code uses unnecessary locking to set VF MTU, resulting in
> deadlock on hot add/remove path. Fix this by using rte_eth_dev_set_mtu()
> to set VF MTU.
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> 
> Fixes: 45c83603087e ("net/netvsc: support MTU set")
> Cc: stable at dpdk.org
> Signed-off-by: Long Li <longli at microsoft.com>
> ---
>  drivers/net/netvsc/hn_vf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c
> index 6b3d0eb0c8..b664beaa5d 100644
> --- a/drivers/net/netvsc/hn_vf.c
> +++ b/drivers/net/netvsc/hn_vf.c
> @@ -264,7 +264,7 @@ int hn_vf_add(struct rte_eth_dev *dev, struct hn_data *hv)
>  			goto exit;
>  		}
>  
> -		ret = hn_vf_mtu_set(dev, dev->data->mtu);
> +		ret = rte_eth_dev_set_mtu(port, dev->data->mtu);
>

As 'rte_eth_dev_set_mtu()' calls 'hn_vf_mtu_set()' in the call chain,
won't it cause same problem?

Does it help to make unlocked version of 'hn_vf_mtu_set()':
```
_hn_vf_mtu_set()
	// set mtu without lock

hn_vf_mtu_set()
	lock()
	_hn_vf_mtu_set()
	unlock()
```


>  		if (ret) {
>  			PMD_DRV_LOG(ERR, "Failed to set VF MTU");
>  			goto exit;
> @@ -796,7 +796,7 @@ int hn_vf_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>  	rte_rwlock_read_lock(&hv->vf_lock);
>  	vf_dev = hn_get_vf_dev(hv);
>  	if (hv->vf_ctx.vf_vsc_switched && vf_dev)
> -		ret = vf_dev->dev_ops->mtu_set(vf_dev, mtu);
> +		ret = rte_eth_dev_set_mtu(vf_dev->data->port_id, mtu);
>

Won't this cause a cyclic call:

rte_eth_dev_set_mtu()
	hn_dev_mtu_set()
		hn_vf_mtu_set()
			rte_eth_dev_set_mtu()
		
>  	rte_rwlock_read_unlock(&hv->vf_lock);
>  
>  	return ret;



More information about the dev mailing list