]> git.itanic.dy.fi Git - linux-stable/commitdiff
net/mlx5: fs, add match on ranges API
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Mon, 15 Aug 2022 09:45:28 +0000 (12:45 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 9 Dec 2022 00:10:53 +0000 (16:10 -0800)
Range is a new flow destination type which allows matching on
a range of values instead of matching on a specific value.

Range flow destination has the following fields:
 - hit_ft: flow table to forward the traffic in case of hit
 - miss_ft: flow table to forward the traffic in case of miss
 - field: which packet characteristic to match on
 - min: minimal value for the selected field
 - max: maximal value for the selected field

Note:
 - In order to match, the value in the packet should meet
   the following criteria: min <= value < max
 - Currently, the only supported field type is L2 packet length

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
include/linux/mlx5/fs.h

index c5bb79a4fa57fd11e07b2a5e0f5b98c10c66a866..2732128e7a6ec98167fd1d0e073732195e29d90f 100644 (file)
@@ -228,6 +228,17 @@ const char *parse_fs_hdrs(struct trace_seq *p,
        return ret;
 }
 
+static const char
+*fs_dest_range_field_to_str(enum mlx5_flow_dest_range_field field)
+{
+       switch (field) {
+       case MLX5_FLOW_DEST_RANGE_FIELD_PKT_LEN:
+               return "packet len";
+       default:
+               return "unknown dest range field";
+       }
+}
+
 const char *parse_fs_dst(struct trace_seq *p,
                         const struct mlx5_flow_destination *dst,
                         u32 counter_id)
@@ -259,6 +270,11 @@ const char *parse_fs_dst(struct trace_seq *p,
        case MLX5_FLOW_DESTINATION_TYPE_PORT:
                trace_seq_printf(p, "port\n");
                break;
+       case MLX5_FLOW_DESTINATION_TYPE_RANGE:
+               trace_seq_printf(p, "field=%s min=%d max=%d\n",
+                                fs_dest_range_field_to_str(dst->range.field),
+                                dst->range.min, dst->range.max);
+               break;
        case MLX5_FLOW_DESTINATION_TYPE_NONE:
                trace_seq_printf(p, "none\n");
                break;
index d53190f22871222d03cdf146af72170a99b64e1d..4dcd26b866627100f03f8e6a877447161246546d 100644 (file)
@@ -448,7 +448,8 @@ static bool is_fwd_dest_type(enum mlx5_flow_destination_type type)
                type == MLX5_FLOW_DESTINATION_TYPE_UPLINK ||
                type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
                type == MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER ||
-               type == MLX5_FLOW_DESTINATION_TYPE_TIR;
+               type == MLX5_FLOW_DESTINATION_TYPE_TIR ||
+               type == MLX5_FLOW_DESTINATION_TYPE_RANGE;
 }
 
 static bool check_valid_spec(const struct mlx5_flow_spec *spec)
@@ -1578,7 +1579,13 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
                    (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM &&
                     d1->ft_num == d2->ft_num) ||
                    (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER &&
-                    d1->sampler_id == d2->sampler_id))
+                    d1->sampler_id == d2->sampler_id) ||
+                   (d1->type == MLX5_FLOW_DESTINATION_TYPE_RANGE &&
+                    d1->range.field == d2->range.field &&
+                    d1->range.hit_ft == d2->range.hit_ft &&
+                    d1->range.miss_ft == d2->range.miss_ft &&
+                    d1->range.min == d2->range.min &&
+                    d1->range.max == d2->range.max))
                        return true;
        }
 
index 3af50fd04d28825e6c2eb41813ca560e4575a838..f137a0611b77b41a7c733b60b1321af60b70c0f3 100644 (file)
@@ -123,6 +123,7 @@ enum mlx5_flow_steering_mode {
 enum mlx5_flow_steering_capabilty {
        MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX = 1UL << 0,
        MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX = 1UL << 1,
+       MLX5_FLOW_STEERING_CAP_MATCH_RANGES = 1UL << 2,
 };
 
 struct mlx5_flow_steering {
index c7a91981cd5af105481855e27bf07d3b3247c110..ba6958b49a8ed48fc15d86de06893c8ad6c15935 100644 (file)
@@ -50,6 +50,7 @@ enum mlx5_flow_destination_type {
        MLX5_FLOW_DESTINATION_TYPE_PORT,
        MLX5_FLOW_DESTINATION_TYPE_COUNTER,
        MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM,
+       MLX5_FLOW_DESTINATION_TYPE_RANGE,
 };
 
 enum {
@@ -143,6 +144,10 @@ enum {
        MLX5_FLOW_DEST_VPORT_REFORMAT_ID  = BIT(1),
 };
 
+enum mlx5_flow_dest_range_field {
+       MLX5_FLOW_DEST_RANGE_FIELD_PKT_LEN = 0,
+};
+
 struct mlx5_flow_destination {
        enum mlx5_flow_destination_type type;
        union {
@@ -156,6 +161,13 @@ struct mlx5_flow_destination {
                        struct mlx5_pkt_reformat *pkt_reformat;
                        u8              flags;
                } vport;
+               struct {
+                       struct mlx5_flow_table         *hit_ft;
+                       struct mlx5_flow_table         *miss_ft;
+                       enum mlx5_flow_dest_range_field field;
+                       u32                             min;
+                       u32                             max;
+               } range;
                u32                     sampler_id;
        };
 };