提交 64fc4b35 编写于 作者: V Vlad Buslov 提交者: Saeed Mahameed

net/mlx5: Bridge, extract VLAN pop code to dedicated functions

Following patches in series need to pop VLAN when packet misses on egress.
To reuse existing bridge VLAN pop handling code, extract it to dedicated
helpers mlx5_esw_bridge_pkt_reformat_vlan_pop_supported() and
mlx5_esw_bridge_pkt_reformat_vlan_pop_create().
Signed-off-by: NVlad Buslov <vladbu@nvidia.com>
Reviewed-by: NPaul Blakey <paulb@nvidia.com>
Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
上级 a1a6e721
...@@ -86,6 +86,26 @@ mlx5_esw_bridge_fdb_del_notify(struct mlx5_esw_bridge_fdb_entry *entry) ...@@ -86,6 +86,26 @@ mlx5_esw_bridge_fdb_del_notify(struct mlx5_esw_bridge_fdb_entry *entry)
SWITCHDEV_FDB_DEL_TO_BRIDGE); SWITCHDEV_FDB_DEL_TO_BRIDGE);
} }
static bool mlx5_esw_bridge_pkt_reformat_vlan_pop_supported(struct mlx5_eswitch *esw)
{
return BIT(MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, reformat_remove)) &&
MLX5_CAP_GEN_2(esw->dev, max_reformat_remove_size) >= sizeof(struct vlan_hdr) &&
MLX5_CAP_GEN_2(esw->dev, max_reformat_remove_offset) >=
offsetof(struct vlan_ethhdr, h_vlan_proto);
}
static struct mlx5_pkt_reformat *
mlx5_esw_bridge_pkt_reformat_vlan_pop_create(struct mlx5_eswitch *esw)
{
struct mlx5_pkt_reformat_params reformat_params = {};
reformat_params.type = MLX5_REFORMAT_TYPE_REMOVE_HDR;
reformat_params.param_0 = MLX5_REFORMAT_CONTEXT_ANCHOR_MAC_START;
reformat_params.param_1 = offsetof(struct vlan_ethhdr, h_vlan_proto);
reformat_params.size = sizeof(struct vlan_hdr);
return mlx5_packet_reformat_alloc(esw->dev, &reformat_params, MLX5_FLOW_NAMESPACE_FDB);
}
static struct mlx5_flow_table * static struct mlx5_flow_table *
mlx5_esw_bridge_table_create(int max_fte, u32 level, struct mlx5_eswitch *esw) mlx5_esw_bridge_table_create(int max_fte, u32 level, struct mlx5_eswitch *esw)
{ {
...@@ -800,24 +820,14 @@ mlx5_esw_bridge_vlan_push_cleanup(struct mlx5_esw_bridge_vlan *vlan, struct mlx5 ...@@ -800,24 +820,14 @@ mlx5_esw_bridge_vlan_push_cleanup(struct mlx5_esw_bridge_vlan *vlan, struct mlx5
static int static int
mlx5_esw_bridge_vlan_pop_create(struct mlx5_esw_bridge_vlan *vlan, struct mlx5_eswitch *esw) mlx5_esw_bridge_vlan_pop_create(struct mlx5_esw_bridge_vlan *vlan, struct mlx5_eswitch *esw)
{ {
struct mlx5_pkt_reformat_params reformat_params = {};
struct mlx5_pkt_reformat *pkt_reformat; struct mlx5_pkt_reformat *pkt_reformat;
if (!BIT(MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, reformat_remove)) || if (!mlx5_esw_bridge_pkt_reformat_vlan_pop_supported(esw)) {
MLX5_CAP_GEN_2(esw->dev, max_reformat_remove_size) < sizeof(struct vlan_hdr) ||
MLX5_CAP_GEN_2(esw->dev, max_reformat_remove_offset) <
offsetof(struct vlan_ethhdr, h_vlan_proto)) {
esw_warn(esw->dev, "Packet reformat REMOVE_HEADER is not supported\n"); esw_warn(esw->dev, "Packet reformat REMOVE_HEADER is not supported\n");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
reformat_params.type = MLX5_REFORMAT_TYPE_REMOVE_HDR; pkt_reformat = mlx5_esw_bridge_pkt_reformat_vlan_pop_create(esw);
reformat_params.param_0 = MLX5_REFORMAT_CONTEXT_ANCHOR_MAC_START;
reformat_params.param_1 = offsetof(struct vlan_ethhdr, h_vlan_proto);
reformat_params.size = sizeof(struct vlan_hdr);
pkt_reformat = mlx5_packet_reformat_alloc(esw->dev,
&reformat_params,
MLX5_FLOW_NAMESPACE_FDB);
if (IS_ERR(pkt_reformat)) { if (IS_ERR(pkt_reformat)) {
esw_warn(esw->dev, "Failed to alloc packet reformat REMOVE_HEADER (err=%ld)\n", esw_warn(esw->dev, "Failed to alloc packet reformat REMOVE_HEADER (err=%ld)\n",
PTR_ERR(pkt_reformat)); PTR_ERR(pkt_reformat));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册