net/mlx5e: Refactor mlx5e flow steering structs
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_tc.c
index b3de09f..ef017c0 100644 (file)
@@ -46,8 +46,8 @@ struct mlx5e_tc_flow {
        struct mlx5_flow_rule   *rule;
 };
 
-#define MLX5E_TC_FLOW_TABLE_NUM_ENTRIES 1024
-#define MLX5E_TC_FLOW_TABLE_NUM_GROUPS 4
+#define MLX5E_TC_TABLE_NUM_ENTRIES 1024
+#define MLX5E_TC_TABLE_NUM_GROUPS 4
 
 static struct mlx5_flow_rule *mlx5e_tc_add_flow(struct mlx5e_priv *priv,
                                                u32 *match_c, u32 *match_v,
@@ -55,33 +55,35 @@ static struct mlx5_flow_rule *mlx5e_tc_add_flow(struct mlx5e_priv *priv,
 {
        struct mlx5_flow_destination dest = {
                .type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE,
-               {.ft = priv->fts.vlan.t},
+               {.ft = priv->fs.vlan.ft.t},
        };
        struct mlx5_flow_rule *rule;
        bool table_created = false;
 
-       if (IS_ERR_OR_NULL(priv->fts.tc.t)) {
-               priv->fts.tc.t =
-                       mlx5_create_auto_grouped_flow_table(priv->fts.ns, 0,
-                                                           MLX5E_TC_FLOW_TABLE_NUM_ENTRIES,
-                                                           MLX5E_TC_FLOW_TABLE_NUM_GROUPS);
-               if (IS_ERR(priv->fts.tc.t)) {
+       if (IS_ERR_OR_NULL(priv->fs.tc.t)) {
+               priv->fs.tc.t =
+                       mlx5_create_auto_grouped_flow_table(priv->fs.ns,
+                                                           MLX5E_TC_PRIO,
+                                                           MLX5E_TC_TABLE_NUM_ENTRIES,
+                                                           MLX5E_TC_TABLE_NUM_GROUPS,
+                                                           0);
+               if (IS_ERR(priv->fs.tc.t)) {
                        netdev_err(priv->netdev,
                                   "Failed to create tc offload table\n");
-                       return ERR_CAST(priv->fts.tc.t);
+                       return ERR_CAST(priv->fs.tc.t);
                }
 
                table_created = true;
        }
 
-       rule = mlx5_add_flow_rule(priv->fts.tc.t, MLX5_MATCH_OUTER_HEADERS,
+       rule = mlx5_add_flow_rule(priv->fs.tc.t, MLX5_MATCH_OUTER_HEADERS,
                                  match_c, match_v,
                                  action, flow_tag,
                                  action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ? &dest : NULL);
 
        if (IS_ERR(rule) && table_created) {
-               mlx5_destroy_flow_table(priv->fts.tc.t);
-               priv->fts.tc.t = NULL;
+               mlx5_destroy_flow_table(priv->fs.tc.t);
+               priv->fs.tc.t = NULL;
        }
 
        return rule;
@@ -93,8 +95,8 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
        mlx5_del_flow_rule(rule);
 
        if (!mlx5e_tc_num_filters(priv)) {
-               mlx5_destroy_flow_table(priv->fts.tc.t);
-               priv->fts.tc.t = NULL;
+               mlx5_destroy_flow_table(priv->fs.tc.t);
+               priv->fs.tc.t = NULL;
        }
 }
 
@@ -310,7 +312,7 @@ static int parse_tc_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
 int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
                           struct tc_cls_flower_offload *f)
 {
-       struct mlx5e_tc_flow_table *tc = &priv->fts.tc;
+       struct mlx5e_tc_table *tc = &priv->fs.tc;
        u32 *match_c;
        u32 *match_v;
        int err = 0;
@@ -376,7 +378,7 @@ int mlx5e_delete_flower(struct mlx5e_priv *priv,
                        struct tc_cls_flower_offload *f)
 {
        struct mlx5e_tc_flow *flow;
-       struct mlx5e_tc_flow_table *tc = &priv->fts.tc;
+       struct mlx5e_tc_table *tc = &priv->fs.tc;
 
        flow = rhashtable_lookup_fast(&tc->ht, &f->cookie,
                                      tc->ht_params);
@@ -401,7 +403,7 @@ static const struct rhashtable_params mlx5e_tc_flow_ht_params = {
 
 int mlx5e_tc_init(struct mlx5e_priv *priv)
 {
-       struct mlx5e_tc_flow_table *tc = &priv->fts.tc;
+       struct mlx5e_tc_table *tc = &priv->fs.tc;
 
        tc->ht_params = mlx5e_tc_flow_ht_params;
        return rhashtable_init(&tc->ht, &tc->ht_params);
@@ -418,12 +420,12 @@ static void _mlx5e_tc_del_flow(void *ptr, void *arg)
 
 void mlx5e_tc_cleanup(struct mlx5e_priv *priv)
 {
-       struct mlx5e_tc_flow_table *tc = &priv->fts.tc;
+       struct mlx5e_tc_table *tc = &priv->fs.tc;
 
        rhashtable_free_and_destroy(&tc->ht, _mlx5e_tc_del_flow, priv);
 
-       if (!IS_ERR_OR_NULL(priv->fts.tc.t)) {
-               mlx5_destroy_flow_table(priv->fts.tc.t);
-               priv->fts.tc.t = NULL;
+       if (!IS_ERR_OR_NULL(tc->t)) {
+               mlx5_destroy_flow_table(tc->t);
+               tc->t = NULL;
        }
 }