On 27/02/2019 17:31, [email protected] wrote:
> From: Tonghao Zhang <[email protected]>
> 
> * Now the encapsulation is not supported for mlx5 VFs. When we try to
> offload that action, the -EINVAL is returned, but not -EOPNOTSUPP.
> This patch changes the returned value and ignore to confuse user.
> The command is shown as below [1].
> 
> * When max modify header action is zero, we return -EOPNOTSUPP
> directly. In this way, we can ignore wrong message info (e.g.
> "mlx5: parsed 0 pedit actions, can't do more"). This happens when
> offloading pedit actions on mlx(cx4) VFs. The command is shown as below [2].
> 
> For example: (p2p1_0 is VF net device)
> [1]
> $ tc filter add dev p2p1_0 protocol ip  parent ffff: prio 1 flower skip_sw \
>     src_mac e4:11:22:33:44:01    \
>     action tunnel_key set        \
>     src_ip 1.1.1.100        \
>     dst_ip 1.1.1.200        \
>     dst_port 4789 id 100        \
>     action mirred egress redirect dev vxlan0
> 
> [2]
> $ tc filter add dev p2p1_0 parent ffff: protocol ip prio 1 \
>     flower skip_sw dst_mac 00:10:56:fb:64:e8 \
>     dst_ip 1.1.1.100 src_ip 1.1.1.200 \
>     action pedit ex munge eth src set 00:10:56:b4:5d:20
> 
> Signed-off-by: Tonghao Zhang <[email protected]>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 27 
> ++++++++++++++++++-------
>  1 file changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 56ac50d..52748e2 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -1999,6 +1999,15 @@ static int offload_pedit_fields(struct 
> pedit_headers_action *hdrs,
>       return 0;
>  }
>  
> +static int mlx5e_flow_namespace_max_modify_action(struct mlx5_core_dev *mdev,
> +                                               int namespace)
> +{
> +     if (namespace == MLX5_FLOW_NAMESPACE_FDB) /* FDB offloading */
> +             return MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, 
> max_modify_header_actions);
> +     else /* namespace is MLX5_FLOW_NAMESPACE_KERNEL - NIC offloading */
> +             return MLX5_CAP_FLOWTABLE_NIC_RX(mdev, 
> max_modify_header_actions);
> +}
> +
>  static int alloc_mod_hdr_actions(struct mlx5e_priv *priv,
>                                struct pedit_headers_action *hdrs,
>                                int namespace,
> @@ -2010,11 +2019,7 @@ static int alloc_mod_hdr_actions(struct mlx5e_priv 
> *priv,
>               hdrs[TCA_PEDIT_KEY_EX_CMD_ADD].pedits;
>       action_size = MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto);
>  
> -     if (namespace == MLX5_FLOW_NAMESPACE_FDB) /* FDB offloading */
> -             max_actions = MLX5_CAP_ESW_FLOWTABLE_FDB(priv->mdev, 
> max_modify_header_actions);
> -     else /* namespace is MLX5_FLOW_NAMESPACE_KERNEL - NIC offloading */
> -             max_actions = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, 
> max_modify_header_actions);
> -
> +     max_actions = mlx5e_flow_namespace_max_modify_action(priv->mdev, 
> namespace);
>       /* can get up to crazingly 16 HW actions in 32 bits pedit SW key */
>       max_actions = min(max_actions, nkeys * 16);
>  
> @@ -2047,6 +2052,12 @@ static int parse_tc_pedit_action(struct mlx5e_priv 
> *priv,
>               goto out_err;
>       }
>  
> +     if (!mlx5e_flow_namespace_max_modify_action(priv->mdev, namespace)) {
> +             NL_SET_ERR_MSG_MOD(extack,
> +                                "The pedit offload action is not supported");
> +             goto out_err;
> +     }
> +
>       mask = act->mangle.mask;
>       val = act->mangle.val;
>       offset = act->mangle.offset;
> @@ -2294,7 +2305,8 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
>                       }
>                       break;
>               default:
> -                     return -EINVAL;
> +                     NL_SET_ERR_MSG_MOD(extack, "The offload action is not 
> supported");
> +                     return -EOPNOTSUPP;
>               }
>       }
>  
> @@ -2616,7 +2628,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
>                       break;
>                       }
>               default:
> -                     return -EINVAL;
> +                     NL_SET_ERR_MSG_MOD(extack, "The offload action is not 
> supported");
> +                     return -EOPNOTSUPP;
>               }
>       }
>  
> 

Reviewed-by: Roi Dayan <[email protected]>

Reply via email to