Commit c25db3a7 authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski

mlxsw: spectrum_router: Enable resolution of nexthop groups from nexthop objects

If the FIB info (i.e, 'struct fib_info', 'struct fib6_info') uses a
nexthop object, then use the object's identifier to resolve the nexthop
group.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2a014b20
...@@ -4648,12 +4648,21 @@ static int mlxsw_sp_nexthop4_group_get(struct mlxsw_sp *mlxsw_sp, ...@@ -4648,12 +4648,21 @@ static int mlxsw_sp_nexthop4_group_get(struct mlxsw_sp *mlxsw_sp,
{ {
struct mlxsw_sp_nexthop_group *nh_grp; struct mlxsw_sp_nexthop_group *nh_grp;
if (fi->nh) {
nh_grp = mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp,
fi->nh->id);
if (WARN_ON_ONCE(!nh_grp))
return -EINVAL;
goto out;
}
nh_grp = mlxsw_sp_nexthop4_group_lookup(mlxsw_sp, fi); nh_grp = mlxsw_sp_nexthop4_group_lookup(mlxsw_sp, fi);
if (!nh_grp) { if (!nh_grp) {
nh_grp = mlxsw_sp_nexthop4_group_create(mlxsw_sp, fi); nh_grp = mlxsw_sp_nexthop4_group_create(mlxsw_sp, fi);
if (IS_ERR(nh_grp)) if (IS_ERR(nh_grp))
return PTR_ERR(nh_grp); return PTR_ERR(nh_grp);
} }
out:
list_add_tail(&fib_entry->nexthop_group_node, &nh_grp->fib_list); list_add_tail(&fib_entry->nexthop_group_node, &nh_grp->fib_list);
fib_entry->nh_group = nh_grp; fib_entry->nh_group = nh_grp;
return 0; return 0;
...@@ -4667,6 +4676,12 @@ static void mlxsw_sp_nexthop4_group_put(struct mlxsw_sp *mlxsw_sp, ...@@ -4667,6 +4676,12 @@ static void mlxsw_sp_nexthop4_group_put(struct mlxsw_sp *mlxsw_sp,
list_del(&fib_entry->nexthop_group_node); list_del(&fib_entry->nexthop_group_node);
if (!list_empty(&nh_grp->fib_list)) if (!list_empty(&nh_grp->fib_list))
return; return;
if (nh_grp->type == MLXSW_SP_NEXTHOP_GROUP_TYPE_OBJ) {
mlxsw_sp_nexthop_obj_group_destroy(mlxsw_sp, nh_grp);
return;
}
mlxsw_sp_nexthop4_group_destroy(mlxsw_sp, nh_grp); mlxsw_sp_nexthop4_group_destroy(mlxsw_sp, nh_grp);
} }
...@@ -5957,8 +5972,17 @@ mlxsw_sp_nexthop6_group_destroy(struct mlxsw_sp *mlxsw_sp, ...@@ -5957,8 +5972,17 @@ mlxsw_sp_nexthop6_group_destroy(struct mlxsw_sp *mlxsw_sp,
static int mlxsw_sp_nexthop6_group_get(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp_nexthop6_group_get(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_fib6_entry *fib6_entry) struct mlxsw_sp_fib6_entry *fib6_entry)
{ {
struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
struct mlxsw_sp_nexthop_group *nh_grp; struct mlxsw_sp_nexthop_group *nh_grp;
if (rt->nh) {
nh_grp = mlxsw_sp_nexthop_obj_group_lookup(mlxsw_sp,
rt->nh->id);
if (WARN_ON_ONCE(!nh_grp))
return -EINVAL;
goto out;
}
nh_grp = mlxsw_sp_nexthop6_group_lookup(mlxsw_sp, fib6_entry); nh_grp = mlxsw_sp_nexthop6_group_lookup(mlxsw_sp, fib6_entry);
if (!nh_grp) { if (!nh_grp) {
nh_grp = mlxsw_sp_nexthop6_group_create(mlxsw_sp, fib6_entry); nh_grp = mlxsw_sp_nexthop6_group_create(mlxsw_sp, fib6_entry);
...@@ -5971,6 +5995,7 @@ static int mlxsw_sp_nexthop6_group_get(struct mlxsw_sp *mlxsw_sp, ...@@ -5971,6 +5995,7 @@ static int mlxsw_sp_nexthop6_group_get(struct mlxsw_sp *mlxsw_sp,
*/ */
__mlxsw_sp_nexthop6_group_offload_refresh(nh_grp, fib6_entry); __mlxsw_sp_nexthop6_group_offload_refresh(nh_grp, fib6_entry);
out:
list_add_tail(&fib6_entry->common.nexthop_group_node, list_add_tail(&fib6_entry->common.nexthop_group_node,
&nh_grp->fib_list); &nh_grp->fib_list);
fib6_entry->common.nh_group = nh_grp; fib6_entry->common.nh_group = nh_grp;
...@@ -5986,6 +6011,12 @@ static void mlxsw_sp_nexthop6_group_put(struct mlxsw_sp *mlxsw_sp, ...@@ -5986,6 +6011,12 @@ static void mlxsw_sp_nexthop6_group_put(struct mlxsw_sp *mlxsw_sp,
list_del(&fib_entry->nexthop_group_node); list_del(&fib_entry->nexthop_group_node);
if (!list_empty(&nh_grp->fib_list)) if (!list_empty(&nh_grp->fib_list))
return; return;
if (nh_grp->type == MLXSW_SP_NEXTHOP_GROUP_TYPE_OBJ) {
mlxsw_sp_nexthop_obj_group_destroy(mlxsw_sp, nh_grp);
return;
}
mlxsw_sp_nexthop6_group_destroy(mlxsw_sp, nh_grp); mlxsw_sp_nexthop6_group_destroy(mlxsw_sp, nh_grp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment