net/mlx5: Add user chosen levels when allocating flow tables
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_fs.c
index 4df49e6..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 {
@@ -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);
 }