Commit c63741b4 authored by Maor Dickman's avatar Maor Dickman Committed by Saeed Mahameed
Browse files

net/mlx5e: Fix MPLSoUDP encap to use MPLS action information



Currently the MPLSoUDP encap builds the MPLS header using encap action
information (tunnel id, ttl and tos) instead of the MPLS action
information (label, ttl, tc and bos) which is wrong.

Fix by storing the MPLS action information during the flow action
parse and later using it to create the encap MPLS header.

Fixes: f828ca6a ("net/mlx5e: Add support for hw encapsulation of MPLS over UDP")
Signed-off-by: default avatarMaor Dickman <maord@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 7fac0529
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ struct mlx5e_tc_act_parse_state {
	bool mpls_push;
	bool ptype_host;
	const struct ip_tunnel_info *tun_info;
	struct mlx5e_mpls_info mpls_info;
	struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];
	int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS];
	int if_count;
+6 −0
Original line number Diff line number Diff line
@@ -177,6 +177,12 @@ parse_mirred_encap(struct mlx5e_tc_act_parse_state *parse_state,
		return -ENOMEM;

	parse_state->encap = false;

	if (parse_state->mpls_push) {
		memcpy(&parse_attr->mpls_info[esw_attr->out_count],
		       &parse_state->mpls_info, sizeof(parse_state->mpls_info));
		parse_state->mpls_push = false;
	}
	esw_attr->dests[esw_attr->out_count].flags |= MLX5_ESW_DEST_ENCAP;
	esw_attr->out_count++;
	/* attr->dests[].rep is resolved when we handle encap */
+11 −0
Original line number Diff line number Diff line
@@ -22,6 +22,16 @@ tc_act_can_offload_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
	return true;
}

static void
copy_mpls_info(struct mlx5e_mpls_info *mpls_info,
	       const struct flow_action_entry *act)
{
	mpls_info->label = act->mpls_push.label;
	mpls_info->tc = act->mpls_push.tc;
	mpls_info->bos = act->mpls_push.bos;
	mpls_info->ttl = act->mpls_push.ttl;
}

static int
tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
		       const struct flow_action_entry *act,
@@ -29,6 +39,7 @@ tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
		       struct mlx5_flow_attr *attr)
{
	parse_state->mpls_push = true;
	copy_mpls_info(&parse_state->mpls_info, act);

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ enum {

struct mlx5e_tc_flow_parse_attr {
	const struct ip_tunnel_info *tun_info[MLX5_MAX_FLOW_FWD_VPORTS];
	struct mlx5e_mpls_info mpls_info[MLX5_MAX_FLOW_FWD_VPORTS];
	struct net_device *filter_dev;
	struct mlx5_flow_spec spec;
	struct mlx5e_tc_mod_hdr_acts mod_hdr_acts;
+3 −0
Original line number Diff line number Diff line
@@ -750,6 +750,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
	struct mlx5e_tc_flow_parse_attr *parse_attr;
	struct mlx5_flow_attr *attr = flow->attr;
	const struct ip_tunnel_info *tun_info;
	const struct mlx5e_mpls_info *mpls_info;
	unsigned long tbl_time_before = 0;
	struct mlx5e_encap_entry *e;
	struct mlx5e_encap_key key;
@@ -760,6 +761,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,

	parse_attr = attr->parse_attr;
	tun_info = parse_attr->tun_info[out_index];
	mpls_info = &parse_attr->mpls_info[out_index];
	family = ip_tunnel_info_af(tun_info);
	key.ip_tun_key = &tun_info->key;
	key.tc_tunnel = mlx5e_get_tc_tun(mirred_dev);
@@ -810,6 +812,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
		goto out_err_init;
	}
	e->tun_info = tun_info;
	memcpy(&e->mpls_info, mpls_info, sizeof(*mpls_info));
	err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack);
	if (err)
		goto out_err_init;
Loading