Skip to content

Commit 3984d1a

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum_router: Provide offload indication using nexthop flags
In a similar fashion to previous patch, use the nexthop flags to provide offload indication instead of the FIB info's flags. In case a nexthop in a multipath route can't be offloaded (gateway's MAC can't be resolved, for example), then its offload flag isn't set. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Tested-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 63e701c commit 3984d1a

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,13 +2103,47 @@ mlxsw_sp_fib_entry_should_offload(const struct mlxsw_sp_fib_entry *fib_entry)
21032103
}
21042104
}
21052105

2106+
static void
2107+
mlxsw_sp_fib4_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry)
2108+
{
2109+
struct mlxsw_sp_nexthop_group *nh_grp = fib_entry->nh_group;
2110+
int i;
2111+
2112+
if (fib_entry->type == MLXSW_SP_FIB_ENTRY_TYPE_LOCAL) {
2113+
nh_grp->nexthops->key.fib_nh->nh_flags |= RTNH_F_OFFLOAD;
2114+
return;
2115+
}
2116+
2117+
for (i = 0; i < nh_grp->count; i++) {
2118+
struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i];
2119+
2120+
if (nh->offloaded)
2121+
nh->key.fib_nh->nh_flags |= RTNH_F_OFFLOAD;
2122+
else
2123+
nh->key.fib_nh->nh_flags &= ~RTNH_F_OFFLOAD;
2124+
}
2125+
}
2126+
2127+
static void
2128+
mlxsw_sp_fib4_entry_offload_unset(struct mlxsw_sp_fib_entry *fib_entry)
2129+
{
2130+
struct mlxsw_sp_nexthop_group *nh_grp = fib_entry->nh_group;
2131+
int i;
2132+
2133+
for (i = 0; i < nh_grp->count; i++) {
2134+
struct mlxsw_sp_nexthop *nh = &nh_grp->nexthops[i];
2135+
2136+
nh->key.fib_nh->nh_flags &= ~RTNH_F_OFFLOAD;
2137+
}
2138+
}
2139+
21062140
static void mlxsw_sp_fib_entry_offload_set(struct mlxsw_sp_fib_entry *fib_entry)
21072141
{
21082142
fib_entry->offloaded = true;
21092143

21102144
switch (fib_entry->fib_node->fib->proto) {
21112145
case MLXSW_SP_L3_PROTO_IPV4:
2112-
fib_info_offload_inc(fib_entry->nh_group->key.fi);
2146+
mlxsw_sp_fib4_entry_offload_set(fib_entry);
21132147
break;
21142148
case MLXSW_SP_L3_PROTO_IPV6:
21152149
WARN_ON_ONCE(1);
@@ -2121,7 +2155,7 @@ mlxsw_sp_fib_entry_offload_unset(struct mlxsw_sp_fib_entry *fib_entry)
21212155
{
21222156
switch (fib_entry->fib_node->fib->proto) {
21232157
case MLXSW_SP_L3_PROTO_IPV4:
2124-
fib_info_offload_dec(fib_entry->nh_group->key.fi);
2158+
mlxsw_sp_fib4_entry_offload_unset(fib_entry);
21252159
break;
21262160
case MLXSW_SP_L3_PROTO_IPV6:
21272161
WARN_ON_ONCE(1);

0 commit comments

Comments
 (0)