1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 // Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
5 #include "en/tc_priv.h"
8 tc_act_can_offload_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
9 const struct flow_action_entry *act,
11 struct mlx5_flow_attr *attr)
13 struct netlink_ext_ack *extack = parse_state->extack;
14 struct mlx5e_tc_flow_parse_attr *parse_attr;
15 struct net_device *out_dev = act->dev;
16 struct mlx5_esw_flow_attr *esw_attr;
18 parse_attr = attr->parse_attr;
19 esw_attr = attr->esw_attr;
24 if (!netif_is_ovs_master(out_dev)) {
25 NL_SET_ERR_MSG_MOD(extack,
26 "redirect to ingress is supported only for OVS internal ports");
30 if (netif_is_ovs_master(parse_attr->filter_dev)) {
31 NL_SET_ERR_MSG_MOD(extack,
32 "redirect to ingress is not supported from internal port");
36 if (!parse_state->ptype_host) {
37 NL_SET_ERR_MSG_MOD(extack,
38 "redirect to int port ingress requires ptype=host action");
42 if (esw_attr->out_count) {
43 NL_SET_ERR_MSG_MOD(extack,
44 "redirect to int port ingress is supported only as single destination");
52 tc_act_parse_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
53 const struct flow_action_entry *act,
54 struct mlx5e_priv *priv,
55 struct mlx5_flow_attr *attr)
57 struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
58 struct net_device *out_dev = act->dev;
61 attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
63 err = mlx5e_set_fwd_to_int_port_actions(priv, attr, out_dev->ifindex,
64 MLX5E_TC_INT_PORT_INGRESS,
65 &attr->action, esw_attr->out_count);
69 parse_state->if_count = 0;
70 esw_attr->out_count++;
75 struct mlx5e_tc_act mlx5e_tc_act_redirect_ingress = {
76 .can_offload = tc_act_can_offload_redirect_ingress,
77 .parse_action = tc_act_parse_redirect_ingress,