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