ssa.c: Configure number of workers in rclose thread pool

Override RCLOSE_THREAD_POOL_WORKERS_NUM in compilation command line
using CFLAGS as follows:
./autogen.sh  && ./configure CFLAGS="-DRCLOSE_THREAD_POOL_WORKERS_NUM=3

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Print number of rlose thread pool workers to ssa log

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
[ssa_mad.h, core.c, ssa.c]: Add bad_parent flag to ssa_member_record

If the flag is "true", a node can't establish upstream connection to
current parent and asks the core for a new one.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Join core node to itself rather than to "MASTER" core

Without the patch, after moving mastership to a new core, it's
distribution tree is wrong. There is no core there.

Also, distribution tree formation doesn't really support two cores
with one is standby.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Handle opened upstream connection if a new parent is received

- If the old and new parents are identical and the connection is alive,
  just move to the CONNECTED state.
- If the parents are different, close the existing upstream connection.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Revert "ssa.c: Avoid rejoin from nodes not directly connected to core"

This reverts commit 846f209c3d62e83b244b9e4d6c9ce5abcaefa581.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Fix rejoin policy to distribution tree

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Implement DB lifecycle support for consumer (ACM) nodes

Destroy previous PRDB after current one completely received
on upstream connection.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_upstream_update_conn, check for additional errors

when handling SSA_DB_FIELD_DEFS and SSA_DB_DATA phases

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_upstream_update_conn, cosmetic change to a couple of log messages

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Cosmetic log message change in ssa_upstream_handle_op

when op is SSA_MSG_DB_UPDATE

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_downstream_notify_db_update, set TID in message header to 0

rather than to svc->tid++

SSA_MSG_DB_UPDATE is an asynchronous message from the upstream
node to the downstream node and is not a transaction as it is
not acknowledged.

Furthermore, incrementing the local TID disrupts the transaction
ID handling.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_upstream_handle_op, ignore DB update message if phase is not IDLE

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_downstream_notify_db_update, don't update sid in ssa_conn struct

as SSA_MSG_DB_UPDATE is not a transaction and won't be matched by TID

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
[ssa.c,core.c,ssa_mad.h] Add bad_parent flag to ssa_member_record.

  If the flag is "true", a node can't establish connection for
  curent parent and asks the core for new one.
Add reconect
ssa.c: Remove trailing whitespace
ssa.c: Skip reconnect if max. count is reached
ssa.c: Add  ssa_upstream_stop_reconnection_timer function
ssa.c: Fix some issues in reconnect