提交 c9ec53f0 编写于 作者: I Ido Schimmel 提交者: David S. Miller

mlxsw: spectrum_router: Determine VR first when creating RIF

All RIF types are associated with a virtual router (VR), so determine VR
first when creating a RIF.

That way, we can more easily integrate the common RIF core in the
following patches.
Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
Signed-off-by: NJiri Pirko <jiri@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8e3482d6
...@@ -3025,19 +3025,21 @@ mlxsw_sp_port_vlan_rif_sp_create(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan, ...@@ -3025,19 +3025,21 @@ mlxsw_sp_port_vlan_rif_sp_create(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
u16 fid, rif_index; u16 fid, rif_index;
int err; int err;
vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
if (IS_ERR(vr))
return ERR_CAST(vr);
rif_index = mlxsw_sp_avail_rif_get(mlxsw_sp); rif_index = mlxsw_sp_avail_rif_get(mlxsw_sp);
if (rif_index == MLXSW_SP_INVALID_INDEX_RIF) if (rif_index == MLXSW_SP_INVALID_INDEX_RIF) {
return ERR_PTR(-ERANGE); err = -ERANGE;
goto err_avail_rif_get;
}
fid = mlxsw_sp_rif_sp_to_fid(rif_index); fid = mlxsw_sp_rif_sp_to_fid(rif_index);
f = mlxsw_sp_rfid_alloc(fid, l3_dev); f = mlxsw_sp_rfid_alloc(fid, l3_dev);
if (!f) if (!f) {
return ERR_PTR(-ENOMEM); err = -ENOMEM;
goto err_rfid_alloc;
vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
if (IS_ERR(vr)) {
err = PTR_ERR(vr);
goto err_vr_get;
} }
rif = mlxsw_sp_rif_alloc(rif_index, vr->id, l3_dev, f, true); rif = mlxsw_sp_rif_alloc(rif_index, vr->id, l3_dev, f, true);
...@@ -3084,9 +3086,10 @@ mlxsw_sp_port_vlan_rif_sp_create(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan, ...@@ -3084,9 +3086,10 @@ mlxsw_sp_port_vlan_rif_sp_create(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
err_port_vlan_rif_sp_op: err_port_vlan_rif_sp_op:
kfree(rif); kfree(rif);
err_rif_alloc: err_rif_alloc:
mlxsw_sp_vr_put(vr);
err_vr_get:
kfree(f); kfree(f);
err_rfid_alloc:
err_avail_rif_get:
mlxsw_sp_vr_put(vr);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -3113,8 +3116,8 @@ mlxsw_sp_port_vlan_rif_sp_destroy(struct mlxsw_sp *mlxsw_sp, ...@@ -3113,8 +3116,8 @@ mlxsw_sp_port_vlan_rif_sp_destroy(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_port_vlan_rif_sp_op(mlxsw_sp, rif, false); mlxsw_sp_port_vlan_rif_sp_op(mlxsw_sp, rif, false);
kfree(rif); kfree(rif);
mlxsw_sp_vr_put(vr);
kfree(f); kfree(f);
mlxsw_sp_vr_put(vr);
} }
static int static int
...@@ -3345,14 +3348,16 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp, ...@@ -3345,14 +3348,16 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp,
u16 rif_index; u16 rif_index;
int err; int err;
rif_index = mlxsw_sp_avail_rif_get(mlxsw_sp);
if (rif_index == MLXSW_SP_INVALID_INDEX_RIF)
return -ERANGE;
vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN); vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
if (IS_ERR(vr)) if (IS_ERR(vr))
return PTR_ERR(vr); return PTR_ERR(vr);
rif_index = mlxsw_sp_avail_rif_get(mlxsw_sp);
if (rif_index == MLXSW_SP_INVALID_INDEX_RIF) {
err = -ERANGE;
goto err_avail_rif_get;
}
rif = mlxsw_sp_rif_alloc(rif_index, vr->id, l3_dev, f, false); rif = mlxsw_sp_rif_alloc(rif_index, vr->id, l3_dev, f, false);
if (!rif) { if (!rif) {
err = -ENOMEM; err = -ENOMEM;
...@@ -3386,6 +3391,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp, ...@@ -3386,6 +3391,7 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp,
err_rif_bridge_op: err_rif_bridge_op:
kfree(rif); kfree(rif);
err_rif_alloc: err_rif_alloc:
err_avail_rif_get:
mlxsw_sp_vr_put(vr); mlxsw_sp_vr_put(vr);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册