On 03/03/2019 11:56, xiangxia.m....@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m....@gmail.com>
> 
> If we try to set VFs rate on a VF (not PF) net device, the kernel
> will be crash. The commands are show as below:
> 
> $ echo 2 > /sys/class/net/$MLX_PF0/device/sriov_numvfs
> $ ip link set $MLX_VF0 vf 0 rate 100

actually this didn't reproduce with this command + your first fix.

setting rate calls netlink IFLA_VF_TX_RATE which is calling
nfo_get_vf_config() which is now returning error correctly.

we need the netlink call to be IFLA_VF_RATE. seems we get there
when we set min/max_tx_rate.
so i reproduce the error with this command
$ ip link set dev $VF vf 0 max_tx_rate 2 max_tx_rate 1

can you verify and fix the commit msg?

> 
> Fixes: c9497c98901c ("net/mlx5: Add support for setting VF min rate")
> Cc: Mohamad Haj Yahia <moha...@mellanox.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m....@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> index 774edc9..8c2f1e6 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> @@ -2122,19 +2122,24 @@ static int normalize_vports_min_rate(struct 
> mlx5_eswitch *esw, u32 divider)
>  int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
>                               u32 max_rate, u32 min_rate)
>  {
> -     u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
> -     bool min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
> -                                     fw_max_bw_share >= MLX5_MIN_BW_SHARE;
> -     bool max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
>       struct mlx5_vport *evport;
> +     u32 fw_max_bw_share;
>       u32 previous_min_rate;
>       u32 divider;
> +     bool min_rate_supported;
> +     bool max_rate_supported;
>       int err = 0;
>  
>       if (!ESW_ALLOWED(esw))
>               return -EPERM;
>       if (!LEGAL_VPORT(esw, vport))
>               return -EINVAL;
> +
> +     fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
> +     min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
> +                             fw_max_bw_share >= MLX5_MIN_BW_SHARE;
> +     max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
> +
>       if ((min_rate && !min_rate_supported) || (max_rate && 
> !max_rate_supported))
>               return -EOPNOTSUPP;
>  
> 

Reply via email to