mlxsw: spectrum_router: Populate adjacency entries according to weights
authorIdo Schimmel <idosch@mellanox.com>
Sun, 22 Oct 2017 21:11:48 +0000 (23:11 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Oct 2017 04:23:06 +0000 (05:23 +0100)
commiteb789980d0aa6cd2ebee3eb07792800bbe134bc0
treefc17c43ea34592456640300fbd070029b8810506
parent425a08c67317acee103b3ad58f57c762e8834faf
mlxsw: spectrum_router: Populate adjacency entries according to weights

Up until now the driver assumed all the nexthops have an equal weight
and wrote each to a single adjacency entry.

This patch takes the `weight` parameter into account and populates the
adjacency group according to the relative weight of each nexthop.

Specifically, the weights of all the nexthops that should be offloaded
are first normalized and then used to calculate the upper adjacency
index of each nexthop. This is done according to the hash-threshold
algorithm used by the kernel for IPv4 multi-path routing.

Adjacency groups are currently limited to 32 entries which limits the
weights that can be used, but follow-up patches will introduce groups of
512 entries.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c