1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 // Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 4 #include "act.h" 5 #include "en/tc_priv.h" 6 #include "en/tc_ct.h" 7 8 static int 9 tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, 10 const struct flow_action_entry *act, 11 struct mlx5e_priv *priv, 12 struct mlx5_flow_attr *attr) 13 { 14 int err; 15 16 err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr, act, parse_state->extack); 17 if (err) 18 return err; 19 20 if (mlx5e_is_eswitch_flow(parse_state->flow)) 21 attr->esw_attr->split_count = attr->esw_attr->out_count; 22 23 attr->flags |= MLX5_ATTR_FLAG_CT; 24 25 return 0; 26 } 27 28 static int 29 tc_act_post_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, 30 struct mlx5e_priv *priv, 31 struct mlx5_flow_attr *attr) 32 { 33 if (!(attr->flags & MLX5_ATTR_FLAG_CT)) 34 return 0; 35 36 return mlx5_tc_ct_flow_offload(parse_state->ct_priv, attr); 37 } 38 39 static bool 40 tc_act_is_multi_table_act_ct(struct mlx5e_priv *priv, 41 const struct flow_action_entry *act, 42 struct mlx5_flow_attr *attr) 43 { 44 if (act->ct.action & TCA_CT_ACT_CLEAR) 45 return false; 46 47 return true; 48 } 49 50 static bool 51 tc_act_is_missable_ct(const struct flow_action_entry *act) 52 { 53 return !(act->ct.action & TCA_CT_ACT_CLEAR); 54 } 55 56 struct mlx5e_tc_act mlx5e_tc_act_ct = { 57 .parse_action = tc_act_parse_ct, 58 .post_parse = tc_act_post_parse_ct, 59 .is_multi_table_act = tc_act_is_multi_table_act_ct, 60 .is_missable = tc_act_is_missable_ct, 61 }; 62 63