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.h"
6
7 static bool
tc_act_can_offload_mark(struct mlx5e_tc_act_parse_state * parse_state,const struct flow_action_entry * act,int act_index,struct mlx5_flow_attr * attr)8 tc_act_can_offload_mark(struct mlx5e_tc_act_parse_state *parse_state,
9 const struct flow_action_entry *act,
10 int act_index,
11 struct mlx5_flow_attr *attr)
12 {
13 if (act->mark & ~MLX5E_TC_FLOW_ID_MASK) {
14 NL_SET_ERR_MSG_MOD(parse_state->extack, "Bad flow mark, only 16 bit supported");
15 return false;
16 }
17
18 return true;
19 }
20
21 static int
tc_act_parse_mark(struct mlx5e_tc_act_parse_state * parse_state,const struct flow_action_entry * act,struct mlx5e_priv * priv,struct mlx5_flow_attr * attr)22 tc_act_parse_mark(struct mlx5e_tc_act_parse_state *parse_state,
23 const struct flow_action_entry *act,
24 struct mlx5e_priv *priv,
25 struct mlx5_flow_attr *attr)
26 {
27 attr->nic_attr->flow_tag = act->mark;
28 attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
29
30 return 0;
31 }
32
33 struct mlx5e_tc_act mlx5e_tc_act_mark = {
34 .can_offload = tc_act_can_offload_mark,
35 .parse_action = tc_act_parse_mark,
36 };
37