APPLIED: [SRU][J][PATCH 1/1] net/mlx5e: TC NIC mode, fix tc chains miss table

Stefan Bader stefan.bader at canonical.com
Fri Jul 8 16:49:29 UTC 2022


On 06.07.22 17:16, Frode Nordahl wrote:
> From: Maor Dickman <maord at nvidia.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1978820
> 
> The cited commit changed promisc table to be created on demand with the
> highest priority in the NIC table replacing the vlan table, this caused
> tc NIC tables miss flow to skip the prmoisc table because it use vlan
> table as miss table.
> 
> OVS offload in NIC mode use promisc by default so any unicast packet
> which will be handled by tc NIC tables miss flow will skip the promisc
> rule and will be dropped.
> 
> Fix this by adding new empty table in new tc level with low priority and
> point the nic tc chain miss to it, the new table is managed so it will
> point to vlan table if promisc is disabled and to promisc table if enabled.
> 
> Fixes: 1c46d7409f30 ("net/mlx5e: Optimize promiscuous mode")
> Signed-off-by: Maor Dickman <maord at nvidia.com>
> Reviewed-by: Paul Blakey <paulb at nvidia.com>
> Reviewed-by: Ariel Levkovich <lariel at nvidia.com>
> Signed-off-by: Saeed Mahameed <saeedm at nvidia.com>
> (cherry picked from commit 66cb64e292d21588bdb831f08a7ec0ff04d6380d master)
> Signed-off-by: Frode Nordahl <frode.nordahl at canonical.com>
> ---

Applied to jammy:linux/master-next. Thanks.

-Stefan

>   .../net/ethernet/mellanox/mlx5/core/en/fs.h   |  2 +
>   .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 38 ++++++++++++++++++-
>   .../net/ethernet/mellanox/mlx5/core/fs_core.c |  2 +-
>   3 files changed, 39 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
> index a88a1a48229f..d634c034a419 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
> @@ -12,6 +12,7 @@ struct mlx5e_post_act;
>   enum {
>   	MLX5E_TC_FT_LEVEL = 0,
>   	MLX5E_TC_TTC_FT_LEVEL,
> +	MLX5E_TC_MISS_LEVEL,
>   };
>   
>   struct mlx5e_tc_table {
> @@ -20,6 +21,7 @@ struct mlx5e_tc_table {
>   	 */
>   	struct mutex			t_lock;
>   	struct mlx5_flow_table		*t;
> +	struct mlx5_flow_table		*miss_t;
>   	struct mlx5_fs_chains           *chains;
>   	struct mlx5e_post_act		*post_act;
>   
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 8b041deb25e5..a41d724df40f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -4982,6 +4982,33 @@ static int mlx5e_tc_nic_get_ft_size(struct mlx5_core_dev *dev)
>   	return tc_tbl_size;
>   }
>   
> +static int mlx5e_tc_nic_create_miss_table(struct mlx5e_priv *priv)
> +{
> +	struct mlx5_flow_table **ft = &priv->fs.tc.miss_t;
> +	struct mlx5_flow_table_attr ft_attr = {};
> +	struct mlx5_flow_namespace *ns;
> +	int err = 0;
> +
> +	ft_attr.max_fte = 1;
> +	ft_attr.autogroup.max_num_groups = 1;
> +	ft_attr.level = MLX5E_TC_MISS_LEVEL;
> +	ft_attr.prio = 0;
> +	ns = mlx5_get_flow_namespace(priv->mdev, MLX5_FLOW_NAMESPACE_KERNEL);
> +
> +	*ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
> +	if (IS_ERR(*ft)) {
> +		err = PTR_ERR(*ft);
> +		netdev_err(priv->netdev, "failed to create tc nic miss table err=%d\n", err);
> +	}
> +
> +	return err;
> +}
> +
> +static void mlx5e_tc_nic_destroy_miss_table(struct mlx5e_priv *priv)
> +{
> +	mlx5_destroy_flow_table(priv->fs.tc.miss_t);
> +}
> +
>   int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
>   {
>   	struct mlx5e_tc_table *tc = &priv->fs.tc;
> @@ -5014,19 +5041,23 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
>   	}
>   	tc->mapping = chains_mapping;
>   
> +	err = mlx5e_tc_nic_create_miss_table(priv);
> +	if (err)
> +		goto err_chains;
> +
>   	if (MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ignore_flow_level))
>   		attr.flags = MLX5_CHAINS_AND_PRIOS_SUPPORTED |
>   			MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED;
>   	attr.ns = MLX5_FLOW_NAMESPACE_KERNEL;
>   	attr.max_ft_sz = mlx5e_tc_nic_get_ft_size(dev);
>   	attr.max_grp_num = MLX5E_TC_TABLE_NUM_GROUPS;
> -	attr.default_ft = mlx5e_vlan_get_flowtable(priv->fs.vlan);
> +	attr.default_ft = priv->fs.tc.miss_t;
>   	attr.mapping = chains_mapping;
>   
>   	tc->chains = mlx5_chains_create(dev, &attr);
>   	if (IS_ERR(tc->chains)) {
>   		err = PTR_ERR(tc->chains);
> -		goto err_chains;
> +		goto err_miss;
>   	}
>   
>   	tc->post_act = mlx5e_tc_post_act_init(priv, tc->chains, MLX5_FLOW_NAMESPACE_KERNEL);
> @@ -5049,6 +5080,8 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
>   	mlx5_tc_ct_clean(tc->ct);
>   	mlx5e_tc_post_act_destroy(tc->post_act);
>   	mlx5_chains_destroy(tc->chains);
> +err_miss:
> +	mlx5e_tc_nic_destroy_miss_table(priv);
>   err_chains:
>   	mapping_destroy(chains_mapping);
>   err_mapping:
> @@ -5089,6 +5122,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv)
>   	mlx5e_tc_post_act_destroy(tc->post_act);
>   	mapping_destroy(tc->mapping);
>   	mlx5_chains_destroy(tc->chains);
> +	mlx5e_tc_nic_destroy_miss_table(priv);
>   }
>   
>   int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> index 4fe189637479..c906b4113ab3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
> @@ -113,7 +113,7 @@
>   #define KERNEL_MIN_LEVEL (KERNEL_NIC_PRIO_NUM_LEVELS + 1)
>   
>   #define KERNEL_NIC_TC_NUM_PRIOS  1
> -#define KERNEL_NIC_TC_NUM_LEVELS 2
> +#define KERNEL_NIC_TC_NUM_LEVELS 3
>   
>   #define ANCHOR_NUM_LEVELS 1
>   #define ANCHOR_NUM_PRIOS 1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20220708/2976150a/attachment.sig>


More information about the kernel-team mailing list