]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
net/mlx5: Refactor mlx5_add_flow_rule
[karo-tx-linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / fs_core.c
index e912a3d2505ed39bee13717224e1c41111a29cda..7fcdae1cf05391d2806d506a6d56e0409efd9e69 100644 (file)
 #define ANCHOR_NUM_LEVELS 1
 #define ANCHOR_NUM_PRIOS 1
 #define ANCHOR_MIN_LEVEL (BY_PASS_MIN_LEVEL + 1)
+
+#define OFFLOADS_MAX_FT 1
+#define OFFLOADS_NUM_PRIOS 1
+#define OFFLOADS_MIN_LEVEL (ANCHOR_MIN_LEVEL + 1)
+
 struct node_caps {
        size_t  arr_sz;
        long    *caps;
@@ -98,7 +103,7 @@ static struct init_tree_node {
        int num_levels;
 } root_fs = {
        .type = FS_TYPE_NAMESPACE,
-       .ar_size = 4,
+       .ar_size = 5,
        .children = (struct init_tree_node[]) {
                ADD_PRIO(0, BY_PASS_MIN_LEVEL, 0,
                         FS_REQUIRED_CAPS(FS_CAP(flow_table_properties_nic_receive.flow_modify_en),
@@ -107,6 +112,9 @@ static struct init_tree_node {
                                          FS_CAP(flow_table_properties_nic_receive.flow_table_modify)),
                         ADD_NS(ADD_MULTIPLE_PRIO(MLX5_BY_PASS_NUM_PRIOS,
                                                  BY_PASS_PRIO_NUM_LEVELS))),
+               ADD_PRIO(0, OFFLOADS_MIN_LEVEL, 0, {},
+                        ADD_NS(ADD_MULTIPLE_PRIO(OFFLOADS_NUM_PRIOS, OFFLOADS_MAX_FT))),
+
                ADD_PRIO(0, KERNEL_MIN_LEVEL, 0, {},
                         ADD_NS(ADD_MULTIPLE_PRIO(1, 1),
                                ADD_MULTIPLE_PRIO(KERNEL_NIC_NUM_PRIOS,
@@ -1152,9 +1160,7 @@ static bool dest_is_valid(struct mlx5_flow_destination *dest,
 
 static struct mlx5_flow_rule *
 _mlx5_add_flow_rule(struct mlx5_flow_table *ft,
-                   u8 match_criteria_enable,
-                   u32 *match_criteria,
-                   u32 *match_value,
+                  struct mlx5_flow_spec *spec,
                    u32 action,
                    u32 flow_tag,
                    struct mlx5_flow_destination *dest)
@@ -1168,22 +1174,23 @@ _mlx5_add_flow_rule(struct mlx5_flow_table *ft,
        nested_lock_ref_node(&ft->node, FS_MUTEX_GRANDPARENT);
        fs_for_each_fg(g, ft)
                if (compare_match_criteria(g->mask.match_criteria_enable,
-                                          match_criteria_enable,
+                                          spec->match_criteria_enable,
                                           g->mask.match_criteria,
-                                          match_criteria)) {
-                       rule = add_rule_fg(g, match_value,
+                                          spec->match_criteria)) {
+                       rule = add_rule_fg(g, spec->match_value,
                                           action, flow_tag, dest);
                        if (!IS_ERR(rule) || PTR_ERR(rule) != -ENOSPC)
                                goto unlock;
                }
 
-       g = create_autogroup(ft, match_criteria_enable, match_criteria);
+       g = create_autogroup(ft, spec->match_criteria_enable,
+                            spec->match_criteria);
        if (IS_ERR(g)) {
                rule = (void *)g;
                goto unlock;
        }
 
-       rule = add_rule_fg(g, match_value,
+       rule = add_rule_fg(g, spec->match_value,
                           action, flow_tag, dest);
        if (IS_ERR(rule)) {
                /* Remove assumes refcount > 0 and autogroup creates a group
@@ -1207,9 +1214,7 @@ static bool fwd_next_prio_supported(struct mlx5_flow_table *ft)
 
 struct mlx5_flow_rule *
 mlx5_add_flow_rule(struct mlx5_flow_table *ft,
-                  u8 match_criteria_enable,
-                  u32 *match_criteria,
-                  u32 *match_value,
+                  struct mlx5_flow_spec *spec,
                   u32 action,
                   u32 flow_tag,
                   struct mlx5_flow_destination *dest)
@@ -1240,8 +1245,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft,
                }
        }
 
-       rule =  _mlx5_add_flow_rule(ft, match_criteria_enable, match_criteria,
-                                   match_value, action, flow_tag, dest);
+       rule = _mlx5_add_flow_rule(ft, spec, action, flow_tag, dest);
 
        if (sw_action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) {
                if (!IS_ERR_OR_NULL(rule) &&
@@ -1369,6 +1373,7 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
 
        switch (type) {
        case MLX5_FLOW_NAMESPACE_BYPASS:
+       case MLX5_FLOW_NAMESPACE_OFFLOADS:
        case MLX5_FLOW_NAMESPACE_KERNEL:
        case MLX5_FLOW_NAMESPACE_LEFTOVERS:
        case MLX5_FLOW_NAMESPACE_ANCHOR: