1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
4 #ifndef __MLX5_EN_TC_ACT_H__
5 #define __MLX5_EN_TC_ACT_H__
7 #include <net/tc_act/tc_pedit.h>
8 #include <net/flow_offload.h>
9 #include <linux/netlink.h>
13 struct mlx5_flow_attr;
15 struct mlx5e_tc_act_parse_state {
16 struct flow_action *flow_action;
17 struct mlx5e_tc_flow *flow;
18 struct netlink_ext_ack *extack;
26 const struct ip_tunnel_info *tun_info;
27 struct mlx5e_mpls_info mpls_info;
28 int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS];
30 struct mlx5_tc_ct_priv *ct_priv;
33 struct mlx5e_tc_act_branch_ctrl {
34 enum flow_action_id act_id;
39 bool (*can_offload)(struct mlx5e_tc_act_parse_state *parse_state,
40 const struct flow_action_entry *act,
42 struct mlx5_flow_attr *attr);
44 int (*parse_action)(struct mlx5e_tc_act_parse_state *parse_state,
45 const struct flow_action_entry *act,
46 struct mlx5e_priv *priv,
47 struct mlx5_flow_attr *attr);
49 int (*post_parse)(struct mlx5e_tc_act_parse_state *parse_state,
50 struct mlx5e_priv *priv,
51 struct mlx5_flow_attr *attr);
53 bool (*is_multi_table_act)(struct mlx5e_priv *priv,
54 const struct flow_action_entry *act,
55 struct mlx5_flow_attr *attr);
57 bool (*is_missable)(const struct flow_action_entry *act);
59 int (*offload_action)(struct mlx5e_priv *priv,
60 struct flow_offload_action *fl_act,
61 struct flow_action_entry *act);
63 int (*destroy_action)(struct mlx5e_priv *priv,
64 struct flow_offload_action *fl_act);
66 int (*stats_action)(struct mlx5e_priv *priv,
67 struct flow_offload_action *fl_act);
69 bool (*get_branch_ctrl)(const struct flow_action_entry *act,
70 struct mlx5e_tc_act_branch_ctrl *cond_true,
71 struct mlx5e_tc_act_branch_ctrl *cond_false);
73 bool is_terminating_action;
76 struct mlx5e_tc_flow_action {
77 unsigned int num_entries;
78 struct flow_action_entry **entries;
81 extern struct mlx5e_tc_act mlx5e_tc_act_drop;
82 extern struct mlx5e_tc_act mlx5e_tc_act_trap;
83 extern struct mlx5e_tc_act mlx5e_tc_act_accept;
84 extern struct mlx5e_tc_act mlx5e_tc_act_mark;
85 extern struct mlx5e_tc_act mlx5e_tc_act_goto;
86 extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap;
87 extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap;
88 extern struct mlx5e_tc_act mlx5e_tc_act_csum;
89 extern struct mlx5e_tc_act mlx5e_tc_act_pedit;
90 extern struct mlx5e_tc_act mlx5e_tc_act_vlan;
91 extern struct mlx5e_tc_act mlx5e_tc_act_vlan_mangle;
92 extern struct mlx5e_tc_act mlx5e_tc_act_mpls_push;
93 extern struct mlx5e_tc_act mlx5e_tc_act_mpls_pop;
94 extern struct mlx5e_tc_act mlx5e_tc_act_mirred;
95 extern struct mlx5e_tc_act mlx5e_tc_act_redirect;
96 extern struct mlx5e_tc_act mlx5e_tc_act_mirred_nic;
97 extern struct mlx5e_tc_act mlx5e_tc_act_ct;
98 extern struct mlx5e_tc_act mlx5e_tc_act_sample;
99 extern struct mlx5e_tc_act mlx5e_tc_act_ptype;
100 extern struct mlx5e_tc_act mlx5e_tc_act_redirect_ingress;
101 extern struct mlx5e_tc_act mlx5e_tc_act_police;
103 struct mlx5e_tc_act *
104 mlx5e_tc_act_get(enum flow_action_id act_id,
105 enum mlx5_flow_namespace_type ns_type);
108 mlx5e_tc_act_init_parse_state(struct mlx5e_tc_act_parse_state *parse_state,
109 struct mlx5e_tc_flow *flow,
110 struct flow_action *flow_action,
111 struct netlink_ext_ack *extack);
114 mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
115 struct flow_action *flow_action, int from, int to,
116 struct mlx5_flow_attr *attr,
117 enum mlx5_flow_namespace_type ns_type);
120 mlx5e_tc_act_set_next_post_act(struct mlx5e_tc_flow *flow,
121 struct mlx5_flow_attr *attr,
122 struct mlx5_flow_attr *next_attr);
124 #endif /* __MLX5_EN_TC_ACT_H__ */