ssa.c: Add support for incoming "set parent" MADs if already connected

Such "set parent" MADs may arrive, as a result of activating
a rebalancing mechanism that might assign downstream node
with a new parent in order to make distribution tree more
balanced in terms of fanout for downstream connections.

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Make ssa_twalk() method public

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
core.c: Add rebalancing mechanism for supporting unordered bringup

The pupose of algorithm for distribution tree rebalancing
is to balance the number of children for distribution
and access layers.

Balanced tree assures that maximum difference in
fanout (number of children) between nodes, that belong
to the same layer, is not more than 1.

The algorithm works as follows:

- Maximum fanout is being calculated per layer

- For each node whose actual fanout is larger
  than the maximum allowed, we take the proper number
  of children, reset their member_record parent_gid
  field and add them to orphan list.

- Orphan list members are being adopted (assigned with
  new parents)

Algorithm purpose is to keep ssa distribution tree
balanced in case of unordered ssa fabric bringup.

IMPORTANT NOTE:
Current rebalancing mechanism might be used at
initial ssa bring-up phase, because it mainly relies
on nodes children counters, that are not updated when
some node leaves the distribution tree.

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
core.c: Make core_start_dtree_timer() method more generic

core_start_dtree_timer() method was renamed to core_start_timer()

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
core.c: Add timer for calling core_rebalance_tree()

Currently core_rebalance_tree() is called only once:
CORE_BALANCE_TIMEOUT seconds after the first subnet up
event.

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
[core ssa].c: Add logging for mutex lock/unlock for debug

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>