opensm: Manage ports that do not support congestion control

Support the ability to run congestion support in an environment
where some IB hardware does not support congestion control.

In addition, by flagging ports that do not support congestion
control, we can reduce the amount of MAD traffic and log messages.

Signed-off-by: Albert Chu <chu11@llnl.gov>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm: osm_pkey: Remove unused variables

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Alex Netes <alexne@mellanox.com>
OpenSM: Add new Mellanox OUI

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
osmtest/osmt_multicast.c: Fix 02BF error

when running osmtest -f m -M 2

Reported-by: Daniel Klein <danielk@mellanox.com>

Sep 04 20:27:28 920578 [D2499700] 0x02 -> osmt_run_mcast_flow: Checking partial JoinState delete request - removing NonMember (o15.0.1.14)...
Sep 04 20:27:28 920863 [D2499700] 0x02 -> osmt_run_mcast_flow: Validating Join State removal of Non Member bit (o15.0.1.14)...
Sep 04 20:27:28 921510 [D2499700] 0x02 -> osmt_run_mcast_flow: Validating Join State update remove (o15.0.1.14)...
Sep 04 20:27:28 921518 [D2499700] 0x01 -> osmt_run_mcast_flow: ERR 02BF: Validating JoinState update failed. Expected 0x25 got: 0x20
Sep 04 20:27:28 921527 [D2499700] 0x01 -> osmtest_run: ERR 0152: Multicast Flow failed: (IB_ERROR)
OSMTEST: TEST "Multicast" FAIL

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/configure.in: check that compiler supports __builtin_expect()

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/complib: define macros for for "if" statements with branch prediction hints

Defined "PT" and "PF" for "predict true"
and "predict false" respectively.

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_node_info_rcv.c: using "PF" hint for all the fatal conditions

This is just the first file - similar optimization will be done
on other MADs receivers.

Note that this patch doesn't mess with all the non-fatal cases.
The goal was not to help SM to perform better with all the
validations that it does, but to make sure that the fatal
cases will never be predicted wrong, so any fatal check (existing
or a newely added one) won't affect the SM performance.

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/libvendor/osm_vendor_ibumad_sa.c: use wrapper function instead of direct access

Use existing wrapper function to get to context instead of direct access.

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/libvendor/osm_vendor_ibumad.c:rename "mad" to "p_mad" to indicate pointer

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/libvendor/osm_vendor_ibumad.c: validate response MAD properties

Check that attribute ID, attribute modifier and
transaction ID are the same in request and response.

Note that just by checking these we cover a very wide
range of possible bugs in SMAs. Attribute modifier is
used in PortInfo, LFT, MFT, and others.

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_port_info_rcv.c: check received local_port_num

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm/osm_port_info_rcv.c: use PF() hint on fatal conditions

Signed-off-by: Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
Signed-off-by: Alex Netes <alexne@mellanox.com>
opensm: Add .gitignore

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Alex Netes <alexne@mellanox.com>
Suppress a compiler warning
Correct opensm man page

Long options have to be preceeded by a double dash instead of a single.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add command-line option --pidfile

This option is necessary to control opensm from an LSB-compliant
init script.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Make it possible to enable opensm with chkconfig

"chkconfig $service on" enables a service in the runlevels mentioned
next to "Default-Start" and only in those runlevels.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Doug Ledford <dledford@redhat.com>
/etc/init.d/opensmd: Improve systemd integration

On recent SLES and openSUSE systems it is necessary to read the
file /lib/lsb/init-functions instead of /etc/rc.status for proper
integration with systemd. Certain implementations of killproc
need a pidfile so make sure that one gets created. Also, correct
the opensm service dependency list.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
opensm.spec.in: Improve portability

Add support for Debian and for other systems that do not support
chkconfig. See also http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/command.html.

Also, after having installed /etc/init.d/opensmd on a system where
systemd is present, tell systemd to reload the files in /etc/init.d.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Fix a compiler warning