net/mlx5e: TC NIC mode, fix tc chains miss table
authorMaor Dickman <maord@nvidia.com>
Mon, 2 May 2022 07:51:30 +0000 (10:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:12 +0000 (18:36 +0200)
[ Upstream commit 66cb64e292d21588bdb831f08a7ec0ff04d6380d ]

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@nvidia.com>
Reviewed-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Ariel Levkovich <lariel@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

index a88a1a48229f60f670ae455dd58f5d95152f13e0..d634c034a419941037e4764c292db35cae9c718f 100644 (file)
@@ -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;
 
index 60a4ac0ca76da30a32736361181c442f0a0558d2..3aa8d0b83d1083a6ae7a227eee29fa643f68b16a 100644 (file)
@@ -4993,6 +4993,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;
@@ -5025,19 +5052,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);
@@ -5060,6 +5091,8 @@ err_reg:
        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:
@@ -5100,6 +5133,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)
index a197dd7ca73bc781ec44840ec7c4ffd3581b0464..379130ed300c654c93ec3b75f1dcaad223cb70fa 100644 (file)
 #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