FILE
ct.c
File preview with syntax highlighting.
linux-6.19.14/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
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 8static bool 9tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state, 10 const struct flow_action_entry *act, 11 int act_index, 12 struct mlx5_flow_attr *attr) 13{ 14 return !((act->ct.action & TCA_CT_ACT_COMMIT) && 15 flow_action_is_last_entry(parse_state->flow_action, act)); 16} 17 18static int 19tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, 20 const struct flow_action_entry *act, 21 struct mlx5e_priv *priv, 22 struct mlx5_flow_attr *attr) 23{ 24 int err; 25 26 err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr, act, parse_state->extack); 27 if (err) 28 return err; 29 30 if (mlx5e_is_eswitch_flow(parse_state->flow)) { 31 attr->esw_attr->split_count = attr->esw_attr->out_count; 32 parse_state->if_count = 0; 33 } 34 35 attr->flags |= MLX5_ATTR_FLAG_CT; 36 37 return 0; 38} 39 40static int 41tc_act_post_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, 42 struct mlx5e_priv *priv, 43 struct mlx5_flow_attr *attr) 44{ 45 if (!(attr->flags & MLX5_ATTR_FLAG_CT)) 46 return 0; 47 48 return mlx5_tc_ct_flow_offload(parse_state->ct_priv, attr); 49} 50 51static bool 52tc_act_is_multi_table_act_ct(struct mlx5e_priv *priv, 53 const struct flow_action_entry *act, 54 struct mlx5_flow_attr *attr) 55{ 56 if (act->ct.action & TCA_CT_ACT_CLEAR) 57 return false; 58 59 return true; 60} 61 62static bool 63tc_act_is_missable_ct(const struct flow_action_entry *act) 64{ 65 return !(act->ct.action & TCA_CT_ACT_CLEAR); 66} 67 68struct mlx5e_tc_act mlx5e_tc_act_ct = { 69 .can_offload = tc_act_can_offload_ct, 70 .parse_action = tc_act_parse_ct, 71 .post_parse = tc_act_post_parse_ct, 72 .is_multi_table_act = tc_act_is_multi_table_act_ct, 73 .is_missable = tc_act_is_missable_ct, 74}; 75
~/
Read-only file preview.