IB/srp: Backport to older kernels

This patch has been tested on RHEL 6.0, RHEL 6.1, RHEL 6.2, RHEL 6.3
and Ubuntu 10.04.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add README

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Fix a race condition

Avoid that srp_claim_command() can claim a command while
srp_queuecommand() is still busy queueing the same command.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Maintain a single connection per I_T nexus

The sysfs attribute 'add_target' may be used to relogin to a
target. An SRP target that receives a second login request from
an initiator will disconnect the previous connection. So before
trying to reconnect, check whether another connection to the
same SRP target identifier already exists. If so, remove the
target port.  Add a target to the target list before connecting
instead of after such that this algorithm has a chance to work.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Micro-optimize completion handlers

Reduce completion queue lock contention by polling for multiple
work completions at once.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Fix srp_abort()

The SCSI error handler assumes that the transport layer is
operational if an eh_abort_handler() returns SUCCESS. Hence let
srp_abort() only return SUCCESS if sending the ABORT TASK task
management function succeeded.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Scan LUNs asynchronously

This avoids that srp_daemon blocks if a communication error occurs
during the scsi_scan_target() call invoked by writing into the
add_target sysfs attribute.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Skip host settle delay

The SRP initiator implements host reset by reconnecting to the SRP
target. That means that communication with the target is possible
as soon as host reset finished. Hence skip the host settle delay.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Add transport layer error handling

Add the necessary functions in the SRP transport module to allow
an SRP initiator driver to implement transport error handling.
This includes:
- Support for implementing fast_io_fail_tmo, the time that should
  elapse after having detected a transport layer problem and
  before failing I/O.
- Support for implementing dev_loss_tmo, the time that should
  elapse after having detected a transport layer problem and
  before removing a remote port.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
scsi_transport_srp: Add dev_loss_tmo and fast_io_fail_tmo module parameters
IB/srp: Add kernel-level transport layer recovery
IB/srp: Speed up error handling

Let srp_abort() return SUCCESS after fast_fail_io_tmo expired such
that the host reset handler won't be invoked if any requests fail
after fast_fail_io_tmo expired.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
IB/srp: Add debug code in srp_abort()
IB/srp: Make HCA completion vector configurable
IB/srp: Avoid deadlock between removal work and transport layer timers
IB/srp: Merge send and receive completion queues
scsi_transport_srp: Add ping support
IB/srp: Add ping support
scsi_transport_srp: Fix a deadlock
scsi_transport_srp: Export rport state to sysfs