Commit 408bd946 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_router: Store weight in nexthop struct

As the first step towards non-equal-cost multi-path support, store each
nexthop's weight.

For IPv6 nexthops always set the weight to 1, as it only supports ECMP.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d672aec4
...@@ -2203,6 +2203,7 @@ struct mlxsw_sp_nexthop { ...@@ -2203,6 +2203,7 @@ struct mlxsw_sp_nexthop {
struct mlxsw_sp_nexthop_key key; struct mlxsw_sp_nexthop_key key;
unsigned char gw_addr[sizeof(struct in6_addr)]; unsigned char gw_addr[sizeof(struct in6_addr)];
int ifindex; int ifindex;
int nh_weight;
struct mlxsw_sp_rif *rif; struct mlxsw_sp_rif *rif;
u8 should_offload:1, /* set indicates this neigh is connected and u8 should_offload:1, /* set indicates this neigh is connected and
* should be put to KVD linear area of this group. * should be put to KVD linear area of this group.
...@@ -3045,6 +3046,11 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, ...@@ -3045,6 +3046,11 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,
nh->nh_grp = nh_grp; nh->nh_grp = nh_grp;
nh->key.fib_nh = fib_nh; nh->key.fib_nh = fib_nh;
#ifdef CONFIG_IP_ROUTE_MULTIPATH
nh->nh_weight = fib_nh->nh_weight;
#else
nh->nh_weight = 1;
#endif
memcpy(&nh->gw_addr, &fib_nh->nh_gw, sizeof(fib_nh->nh_gw)); memcpy(&nh->gw_addr, &fib_nh->nh_gw, sizeof(fib_nh->nh_gw));
err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh); err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh);
if (err) if (err)
...@@ -4304,6 +4310,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, ...@@ -4304,6 +4310,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp,
struct net_device *dev = rt->dst.dev; struct net_device *dev = rt->dst.dev;
nh->nh_grp = nh_grp; nh->nh_grp = nh_grp;
nh->nh_weight = 1;
memcpy(&nh->gw_addr, &rt->rt6i_gateway, sizeof(nh->gw_addr)); memcpy(&nh->gw_addr, &rt->rt6i_gateway, sizeof(nh->gw_addr));
mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh);
......
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