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 
7 static bool
tc_act_can_offload_ptype(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_ptype(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 	return true;
14 }
15 
16 static int
tc_act_parse_ptype(struct mlx5e_tc_act_parse_state * parse_state,const struct flow_action_entry * act,struct mlx5e_priv * priv,struct mlx5_flow_attr * attr)17 tc_act_parse_ptype(struct mlx5e_tc_act_parse_state *parse_state,
18 		   const struct flow_action_entry *act,
19 		   struct mlx5e_priv *priv,
20 		   struct mlx5_flow_attr *attr)
21 {
22 	struct netlink_ext_ack *extack = parse_state->extack;
23 
24 	if (act->ptype != PACKET_HOST) {
25 		NL_SET_ERR_MSG_MOD(extack, "skbedit ptype is only supported with type host");
26 		return -EOPNOTSUPP;
27 	}
28 
29 	parse_state->ptype_host = true;
30 	return 0;
31 }
32 
33 struct mlx5e_tc_act mlx5e_tc_act_ptype = {
34 	.can_offload = tc_act_can_offload_ptype,
35 	.parse_action = tc_act_parse_ptype,
36 };
37