Commit 442b3d7b authored by Jianbo Liu's avatar Jianbo Liu Committed by Saeed Mahameed
Browse files

net/mlx5: Set reformat action when needed for termination rules



For remote mirroring, after the tunnel packets are received, they are
decapsulated and sent to representor, then re-encapsulated and sent
out over another tunnel. So reformat action is set only when the
destination is required to do encapsulation.

Fixes: 249ccc3c ("net/mlx5e: Add support for offloading traffic from uplink to uplink")
Signed-off-by: default avatarJianbo Liu <jianbol@nvidia.com>
Reviewed-by: default avatarAriel Levkovich <lariel@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent dca59f4a
Loading
Loading
Loading
Loading
+10 −21
Original line number Original line Diff line number Diff line
@@ -172,19 +172,6 @@ mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw,
	}
	}
}
}


static bool mlx5_eswitch_termtbl_is_encap_reformat(struct mlx5_pkt_reformat *rt)
{
	switch (rt->reformat_type) {
	case MLX5_REFORMAT_TYPE_L2_TO_VXLAN:
	case MLX5_REFORMAT_TYPE_L2_TO_NVGRE:
	case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL:
	case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL:
		return true;
	default:
		return false;
	}
}

static void
static void
mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
				  struct mlx5_flow_act *dst)
				  struct mlx5_flow_act *dst)
@@ -202,14 +189,6 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
			memset(&src->vlan[1], 0, sizeof(src->vlan[1]));
			memset(&src->vlan[1], 0, sizeof(src->vlan[1]));
		}
		}
	}
	}

	if (src->action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT &&
	    mlx5_eswitch_termtbl_is_encap_reformat(src->pkt_reformat)) {
		src->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
		dst->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
		dst->pkt_reformat = src->pkt_reformat;
		src->pkt_reformat = NULL;
	}
}
}


static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
@@ -279,6 +258,14 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
		if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
		if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
			continue;
			continue;


		if (attr->dests[num_vport_dests].flags & MLX5_ESW_DEST_ENCAP) {
			term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
			term_tbl_act.pkt_reformat = attr->dests[num_vport_dests].pkt_reformat;
		} else {
			term_tbl_act.action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
			term_tbl_act.pkt_reformat = NULL;
		}

		/* get the terminating table for the action list */
		/* get the terminating table for the action list */
		tt = mlx5_eswitch_termtbl_get_create(esw, &term_tbl_act,
		tt = mlx5_eswitch_termtbl_get_create(esw, &term_tbl_act,
						     &dest[i], attr);
						     &dest[i], attr);
@@ -301,6 +288,8 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
		goto revert_changes;
		goto revert_changes;


	/* create the FTE */
	/* create the FTE */
	flow_act->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
	flow_act->pkt_reformat = NULL;
	rule = mlx5_add_flow_rules(fdb, spec, flow_act, dest, num_dest);
	rule = mlx5_add_flow_rules(fdb, spec, flow_act, dest, num_dest);
	if (IS_ERR(rule))
	if (IS_ERR(rule))
		goto revert_changes;
		goto revert_changes;