net/mlx5: Add user chosen levels when allocating flow tables
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_fs.c
index d00a242..d61171a 100644 (file)
 #include <linux/mlx5/fs.h>
 #include "en.h"
 
+enum {
+       MLX5E_VLAN_FT_LEVEL = 0,
+       MLX5E_MAIN_FT_LEVEL
+};
+
 #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
 
 enum {
@@ -247,7 +252,7 @@ static int __mlx5e_add_eth_addr_rule(struct mlx5e_priv *priv,
                                   outer_headers.dmac_47_16);
        u8 *mv_dmac = MLX5_ADDR_OF(fte_match_param, mv,
                                   outer_headers.dmac_47_16);
-       u32 *tirn = priv->tirn;
+       u32 *tirn = priv->indir_tirn;
        u32 tt_vec;
        int err = 0;
 
@@ -274,7 +279,7 @@ static int __mlx5e_add_eth_addr_rule(struct mlx5e_priv *priv,
 
        if (tt_vec & BIT(MLX5E_TT_ANY)) {
                rule_p = &ai->ft_rule[MLX5E_TT_ANY];
-               dest.tir_num = tirn[MLX5E_TT_ANY];
+               dest.tir_num = priv->direct_tir[0].tirn;
                *rule_p = mlx5_add_flow_rule(ft, match_criteria_enable, mc, mv,
                                             MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
                                             MLX5_FS_DEFAULT_FLOW_TAG, &dest);
@@ -1041,7 +1046,8 @@ static int mlx5e_create_main_flow_table(struct mlx5e_priv *priv)
        int err;
 
        ft->num_groups = 0;
-       ft->t = mlx5_create_flow_table(priv->fts.ns, 1, MLX5E_MAIN_TABLE_SIZE);
+       ft->t = mlx5_create_flow_table(priv->fts.ns, 1, MLX5E_MAIN_TABLE_SIZE,
+                                      MLX5E_MAIN_FT_LEVEL);
 
        if (IS_ERR(ft->t)) {
                err = PTR_ERR(ft->t);
@@ -1150,7 +1156,8 @@ static int mlx5e_create_vlan_flow_table(struct mlx5e_priv *priv)
        int err;
 
        ft->num_groups = 0;
-       ft->t = mlx5_create_flow_table(priv->fts.ns, 1, MLX5E_VLAN_TABLE_SIZE);
+       ft->t = mlx5_create_flow_table(priv->fts.ns, 1, MLX5E_VLAN_TABLE_SIZE,
+                                      MLX5E_VLAN_FT_LEVEL);
 
        if (IS_ERR(ft->t)) {
                err = PTR_ERR(ft->t);
@@ -1167,11 +1174,16 @@ static int mlx5e_create_vlan_flow_table(struct mlx5e_priv *priv)
        if (err)
                goto err_free_g;
 
+       err = mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_UNTAGGED, 0);
+       if (err)
+               goto err_destroy_vlan_flow_groups;
+
        return 0;
 
+err_destroy_vlan_flow_groups:
+       mlx5e_destroy_groups(ft);
 err_free_g:
        kfree(ft->g);
-
 err_destroy_vlan_flow_table:
        mlx5_destroy_flow_table(ft->t);
        ft->t = NULL;
@@ -1194,15 +1206,11 @@ int mlx5e_create_flow_tables(struct mlx5e_priv *priv)
        if (!priv->fts.ns)
                return -EINVAL;
 
-       err = mlx5e_create_vlan_flow_table(priv);
-       if (err)
-               return err;
-
        err = mlx5e_create_main_flow_table(priv);
        if (err)
-               goto err_destroy_vlan_flow_table;
+               return err;
 
-       err = mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_UNTAGGED, 0);
+       err = mlx5e_create_vlan_flow_table(priv);
        if (err)
                goto err_destroy_main_flow_table;
 
@@ -1210,8 +1218,6 @@ int mlx5e_create_flow_tables(struct mlx5e_priv *priv)
 
 err_destroy_main_flow_table:
        mlx5e_destroy_main_flow_table(priv);
-err_destroy_vlan_flow_table:
-       mlx5e_destroy_vlan_flow_table(priv);
 
        return err;
 }
@@ -1219,6 +1225,6 @@ err_destroy_vlan_flow_table:
 void mlx5e_destroy_flow_tables(struct mlx5e_priv *priv)
 {
        mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_UNTAGGED, 0);
-       mlx5e_destroy_main_flow_table(priv);
        mlx5e_destroy_vlan_flow_table(priv);
+       mlx5e_destroy_main_flow_table(priv);
 }