Message ID | 1548156126-8021-2-git-send-email-xiangxia.m.yue@gmail.com |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | [net-next,v3,1/2] net/mlx5e: Update hw flows when encap source mac changed | expand |
On Tue, Jan 22, 2019 at 4:38 PM <xiangxia.m.yue@gmail.com> wrote: > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com> > > In some case, we may use multiple pedit actions to modify packets. > The command shown as below: the last pedit action is effective. > > $ tc filter add dev netdev_rep parent ffff: protocol ip prio 1 \ > flower skip_sw ip_proto icmp dst_ip 3.3.3.3 \ > action pedit ex munge ip dst set 192.168.1.100 pipe \ > action pedit ex munge eth src set 00:00:00:00:00:01 pipe \ > action pedit ex munge eth dst set 00:00:00:00:00:02 pipe \ > action csum ip pipe \ > action tunnel_key set src_ip 1.1.1.100 dst_ip 1.1.1.200 dst_port 4789 id 100 \ > action mirred egress redirect dev vxlan0 > > To fix it, we add max_mod_hdr_actions to mlx5e_tc_flow_parse_attr struction, > max_mod_hdr_actions will store the max pedit action number we support and > num_mod_hdr_actions indicates how many pedit action we used, and store all > pedit action to mod_hdr_actions. There's a comment just above offload_pedit_fields saying: /* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at * max from the SW pedit action. On success, it says how many HW actions were * actually parsed. */ I guess it will have to change now, right?
On Fri, Jan 25, 2019 at 1:21 AM Or Gerlitz <gerlitz.or@gmail.com> wrote: > > On Tue, Jan 22, 2019 at 4:38 PM <xiangxia.m.yue@gmail.com> wrote: > > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com> > > > > In some case, we may use multiple pedit actions to modify packets. > > The command shown as below: the last pedit action is effective. > > > > $ tc filter add dev netdev_rep parent ffff: protocol ip prio 1 \ > > flower skip_sw ip_proto icmp dst_ip 3.3.3.3 \ > > action pedit ex munge ip dst set 192.168.1.100 pipe \ > > action pedit ex munge eth src set 00:00:00:00:00:01 pipe \ > > action pedit ex munge eth dst set 00:00:00:00:00:02 pipe \ > > action csum ip pipe \ > > action tunnel_key set src_ip 1.1.1.100 dst_ip 1.1.1.200 dst_port 4789 id 100 \ > > action mirred egress redirect dev vxlan0 > > > > To fix it, we add max_mod_hdr_actions to mlx5e_tc_flow_parse_attr struction, > > max_mod_hdr_actions will store the max pedit action number we support and > > num_mod_hdr_actions indicates how many pedit action we used, and store all > > pedit action to mod_hdr_actions. > > There's a comment just above offload_pedit_fields saying: > > /* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at > * max from the SW pedit action. On success, it says how many HW actions were > * actually parsed. > */ > > I guess it will have to change now, right? yes, v4 will be sent
On Tue, Jan 22, 2019 at 4:38 PM <xiangxia.m.yue@gmail.com> wrote: > From: Tonghao Zhang <xiangxia.m.yue@gmail.com> > > In some case, we may use multiple pedit actions to modify packets. just to clarify, this is a matter of choice, right? in other words, it doesn't buy you extra functionality > The command shown as below: the last pedit action is effective. and we are leaking some memory / HW (modify header instance) objects in the driver, as of that, right? this makes your patch a fix which should be labeled by "net" and not "net-next", same goes to the neigh update fix, would be good if you repost them with net labeling.
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index cae6c6d..2ee377a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -128,6 +128,7 @@ struct mlx5e_tc_flow_parse_attr { struct net_device *filter_dev; struct mlx5_flow_spec spec; int num_mod_hdr_actions; + int max_mod_hdr_actions; void *mod_hdr_actions; int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS]; }; @@ -1960,8 +1961,9 @@ static int offload_pedit_fields(struct pedit_headers *masks, add_vals = &vals[TCA_PEDIT_KEY_EX_CMD_ADD]; action_size = MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto); - action = parse_attr->mod_hdr_actions; - max_actions = parse_attr->num_mod_hdr_actions; + action = parse_attr->mod_hdr_actions + + parse_attr->num_mod_hdr_actions * action_size; + max_actions = parse_attr->max_mod_hdr_actions; nactions = 0; for (i = 0; i < ARRAY_SIZE(fields); i++) { @@ -2048,7 +2050,7 @@ static int offload_pedit_fields(struct pedit_headers *masks, nactions++; } - parse_attr->num_mod_hdr_actions = nactions; + parse_attr->num_mod_hdr_actions += nactions; return 0; } @@ -2073,7 +2075,8 @@ static int alloc_mod_hdr_actions(struct mlx5e_priv *priv, if (!parse_attr->mod_hdr_actions) return -ENOMEM; - parse_attr->num_mod_hdr_actions = max_actions; + parse_attr->max_mod_hdr_actions = max_actions; + parse_attr->num_mod_hdr_actions = 0; return 0; } @@ -2119,9 +2122,11 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv, goto out_err; } - err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); - if (err) - goto out_err; + if (!parse_attr->mod_hdr_actions) { + err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); + if (err) + goto out_err; + } err = offload_pedit_fields(masks, vals, parse_attr, extack); if (err < 0)