opensm: Move per_mod_log_tbl array from subn to log structure

Having per_mod_log_tbl as part of subn structure is problematic because it means that
subn structure should be part of libopensm which is highly undesired, so moving
per_mod_log_tbl array from subn to log structure breaks that coupling.

Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
opensm: Add initial congestion control configuration support

This patch adds initial support for congestion control configuration
on a fabric.  Users may configure settings via the Switch Congestion
Setting, CA Congestion Setting, or Congest Control Table MADs.

Signed-off-by: Albert Chu <chu11@llnl.gov>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/torus-2QoS: Fix some typos in documentation

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Add support to reread configuration file when stacked in rediscovery loop.

If SM is stucked in continuous rediscovery loop, it will never reach
rereading the configuration files.

Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_link_mgr.c: Set PortInfo:PortState to LinkDown when remote port isn't accessible

There might be a scenario where port's link physical state is LinkUp,
but port's peer doesn't answer to SMPs. In this case we will move the port
to LinkDown.

Signed-off-by: Daniel Klein <danielk@mellanox.com>
Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Fixed Multicast precreation parsing

Now allow to define partition without members with only multicast group
definitions.

Default=0x7fff : ALL;
Default=0x7fff,ipoib:
        mgid=ff12:401b::0719;

Signed-off-by: Tamir Ronen <tamirr@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Fixed crash in sm_state_mgr_send_master_sm_info_req() during fabric merge

The scenario that led to a crash is as follows:
1. Our SM in MASTER state discovered another MASTER SM with lower priority.
2. Our SM waited for a HANDOVER and started to poll (SMInfoGet) the other SM.
3. Other SM's port/node disconnected from the fabric and didn't update the sm->p_remote_sm - pointer to the other SM.

Fix is to osm_remote_sm struct.
Remove p_port from remote osm_remote_sm struct.
Fix cleanup of sm->p_polling_sm in drop manager.
Add read lock during SM polling timer.

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
opensm/osm_subnet.c: Cosmetic formatting change

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Fix deadlock between sminfo_set_req() and osm_sm_state_mgr()

A deadlock will occur when SM with higher priority gets HANDOVER
message during the state manager when it start polling the current MASTER SM.

Both sminfo_set_req() and osm_sm_state_mgr() use two locks -
sm->p_lock and sm->state_lock but in reverse order. This scenario
can lead to a deadlock.

Signed-off-by: Alex Netes <alexne@mellanox.com>
Fixes in SL2VL table distribution algorithm

SL2VL and VLARB table shouldn't be sent to DOWN ports

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Sending SL2VL and VLARB SET MADs in distributed manner

The algorithm is the following:
1. For each GUID the linked list of QoS MADs is created w/o sending the
   MADs.
2. These linked lists are combined into super-linked list. The nodes in
   the super-list are linked lists from Action 1.
3. Now I'm traversing the super-linked list until it is empty and
   removing the head items from the GUID QoS MAD lists and sending them
   over the wire.

Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Fix SL2VL configuration

Set optimized SL2VL table only if node is maked as 'need_update'.
Set SL2VL tale for port that marked as 'need_update'.

Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Vladimir Koushnir <vladimirk@mellanox.com>
Fix base port0 sl2vl mapping optimization

The settings should be saved to the port that was used during the calculation
and not port 0 by default.

Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa_mcmember_record.c: Dump MCMemberRecord in mcmr_query_mgrp

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Fix pre-creation of MC group with MGID containing P_Key

IPoIB MGID can contain only full P_Key.

Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa_mcmember_record.c: In mcmr_rcv_join_mgrp, add MGID to log message

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa_path_record.c: Add debug logging to pr_match_mgrp_attributes

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa_path_record.c: Log requester port GUID at DEBUG level

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa_mcmember_record.c: Log requester port GUID at DEBUG level

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_sa*.c: Log requester port GUID at DEBUG level

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>