Commit Graph

33 Commits

Author SHA1 Message Date
Arne Redlich
6edf993507 Make headers in include/ digestible for C++
Also removes trailing whitespace in these files.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2012-07-08 13:38:41 +02:00
Ronnie Sahlberg
9e5535adfd Reconnect: If we are logged in and we experience a session failure, then
try to re-connect and redrive all I/O

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2012-05-01 18:46:30 +10:00
Ronnie Sahlberg
50594830bd Task Management. When we abort a task or a task set, or reset the lun or target
we must also cancel all active tasks.
This will trigger all affected tasks to have their callback invoked with
SCSI_STATUS_CANCELLED
2012-03-10 12:12:47 +11:00
Ronnie Sahlberg
cff996a96d VERIFY10: Add support for VERIFY10. Also add a simple test for verify10 2012-01-26 15:47:14 +11:00
Paolo Bonzini
b4a48511ff fix warning from -Wenum-compare 2011-09-21 11:49:58 +02:00
Ronnie Sahlberg
c3d3123981 Windows: Add support to build as a DLL under windows 2011-08-31 13:12:30 +10:00
Ronnie Sahlberg
3a39201543 Add 'zero-copy' in libiscsi for reads.
It is not real zero-copy since the data is still copied in the kernel,
but it avoids copying the data inside libiscsi as well as in the callback.

For SCSI tasks that will return data from the target, the application can now
specify application buffers for libiscsi to read the data directly into.
This is done by calling scsi_task_add_data_in_buffer(task, ...

These buffers need not be linear, you can specify different areas to read into
by calling this function several times.

See examples/iscsiclient.c for an example.
2011-04-20 05:46:17 +10:00
Ronnie Sahlberg
ef846b0f30 Target initiated NOP:
Initial support to try to respond to target initiated NOPs.
2011-04-10 15:33:42 +10:00
Ronnie Sahlberg
f4f6ef5033 change dont automatically free the scsi_task once the callback completes.
Freeing the scsi_task structure is the responsibility of the application
to either do so during the callback, or later.
2011-03-27 17:53:05 +11:00
Ronnie Sahlberg
4e6e39ee23 Support for REJECT PDUs. 2011-02-27 13:49:49 +11:00
Ronnie Sahlberg
356a6571bb Login: remember what the TargetAddress returned during login is so we can
handle redirect 'errors'.
2011-02-25 15:35:49 +11:00
Ronnie Sahlberg
e9749ee68c Add ifdefs to protect the header files from being included
multiple times

From Richard Sharpe
2011-02-25 14:25:45 +11:00
Ronnie Sahlberg
3dfdebcba7 TaskMgmt : Add an initial function to create a iscsi tm PDU 2011-02-15 21:53:47 +11:00
Ronnie Sahlberg
332ea04e8d TaskMgmt: Add a functionto set the Reference cmdsn for tm pdus 2011-02-15 21:44:16 +11:00
Ronnie Sahlberg
95db35e592 TaskMgmt: add a function to set the ritt for tm pdus 2011-02-15 21:42:23 +11:00
Ronnie Sahlberg
2c093d86a6 whitespace changes to the list of pdu types 2011-02-15 21:26:26 +11:00
Ronnie Sahlberg
704288169f Add task management pdu request and response constants to the list of pdu types 2011-02-15 21:24:24 +11:00
Ronnie Sahlberg
74fadc9337 Add support for R2T PDUs.
Update the "send scsi command" fucntion to honour
"FirstBurstLength" so that we only send this many bytes as unsolicited data.

The wait for a train of R2T from the target to clock out additional
busrts of data until the full task data has been sent to the Target.

We should now honour, and handle the case of
ImmediateData=No
InitialR2T=No
correctly for targets that are limited on receiveing data too fast.
2011-01-02 19:27:32 +11:00
Ronnie Sahlberg
d240e8b5aa Use an initiator specific and one target specific value for MaxRecvDataSegmentLength 2011-01-02 19:27:16 +11:00
Ronnie Sahlberg
5e5d6c05c0 Add a function to send DATAOUT PDUs.
Update the send pdu command to trap when we need to send data to the target
but we are not allowed to send using immediate data.
For this case, send the data as a separate DATAOUT pdu instead.

Twiddle the flags and other fields to now manage that we send the data
as two separate PDUs.
2011-01-02 18:01:21 +11:00
Ronnie Sahlberg
9a8fca8bea Add two new helpers iscsi_pdu_set_[datasn|bufferoffset]()
These two helpers can be used to set the corresponding fields in a
DATAOUT PDU
2011-01-02 18:01:08 +11:00
Ronnie Sahlberg
9cd03ca559 Add a new helper function iscsi_allocate_pdu_with_itt_flags()
This function can allocate a new pdu using a specific itt value
and specific flags instead of using the defaults of, next iff, no flags set.

This can be used when we need to allocate additional PDUs in a chain,
for commands that span across multiple PDUs and where all need to keep
the same itt value.

For example
   ->WRITE10 cdb
   ->DATAOUT
   -<RESPONSE

Here the DATAOUT PDU belongs to the same task that was started by write10
so it need to use the same itt value.
2011-01-02 18:01:00 +11:00
Ronnie Sahlberg
1569624fd2 Add a new helper function _set_itt() that can be used to set the itt of
a pdu, instead of having to twiddle the bits and bytes manually.
2011-01-02 18:00:46 +11:00
Ronnie Sahlberg
72f9d8fa82 Add a new pdu flag : NO_CALLBACK
This flag is used when we dont want the CANCEL callback to be invoked if the
context is destroyed.

Thsi will be used for the sequence where we send multiple PDUs
to the target for one single scsi task, such as
    -> WRITE10 cdb
    -> DATAOUT
    -< RESPONSE

Since if the context is destroyed when the command is in flight, we
already get the CANCEL callback for the WRITE10 PDU, so we dont need to invoke
it again for when we destroy the DATAOUT pdu, since they both refer to the same
task.
2011-01-02 18:00:37 +11:00
Ronnie Sahlberg
490a01053a Add a flags field to the pdu structure
Add a new pdu flag : DELETE_WHEN_SENT. When this pdu has been
sent to the wire, the pdu will be deleted and not put on the waitpdu list.

This will be useful for sequences such as
    -> WRITE10 cdb
    -> DATAOUT the data to write
    -< RESPONSE

Where we want to match WRITE10 and RESPONSE but where the plain DATAOUT pdu
will not be soliciting its own response.
We dont need to wait for the response to DATAOUT pdus, we are already waitin
for the response form the initial PDU in the sequence.
2011-01-02 18:00:19 +11:00
Ronnie Sahlberg
1f1e5111d4 Negotiate ImmediateData during login and store the result in iscsi->
We will use this later to decide when we should send unsolicited imemdiate
data to the target. Currently we always send unsolicited immediate data
but targets configured to not allow immediate data may refuce this and
turn an error.
2011-01-02 12:59:41 +11:00
Ronnie Sahlberg
32228a4509 Negotiate InitialR2T during login. Default to offer No, but update
and accept what Target responds.

Store the result of the negotiated setting in the iscsi context
so we can use it later to determine how to send solicited/unsolicited
data.
2011-01-02 12:50:00 +11:00
Ronnie Sahlberg
a3328a85ef Negotiation of MaxBurstLength, FirstBurstLength, MaxRecvDataSegmentLength
Add these settings to the iscsi context structure and initialize them to
sane valued.
When sending login commands to the target, use these values instead
of hardcoded values.
Parse when the target sends a login reply back to us and update these variables
if the target asks us to.

This allows us to detect when our defaults are too big for the target
and adjust the settings we use so we match the target.

Some targets have a very small accepted default for some settings.
During login, we will initially send these keys with our dafult values.
These targets will then respond back by refusing to transition to the next
login phase, and by telling us back what the maximum of these values should be.
In this case we have to try the login again but use the smaller values we got
from the target.
Othervise, if we try again, ignoring the value from the target, and just repeat
using our defaults the target will abort the login with a "initiator error".
2011-01-01 09:51:16 +11:00
Ronnie Sahlberg
40abe849b0 CHAP
Add unidirectional chap support so we can authenticate to the target.

Make the login phase more "intelligent" so we can iterate over login
pdus until we have reached full feature phase

Add a new helper functions to parse a iscsi url and break it down
into elements in a structure

Update iscsi-inq to allow CHAP authentication
2010-12-22 22:23:55 +11:00
Ronnie Sahlberg
1c024d6bc4 Input processing:
Input processing used to keep all data in one single input buffer, which
makes it hard to handle nested events as well as reading directly from the
socket into the application buffer without an extra copy.

Create a new iscsi_in_pdu structure where we store the header, and any data
for the recevied pdu and store them in a proper input queue.

Change the signature for all processing functions to tahe a iscsi_in_pdu
structure for the received pdu instead of just a pointer to a buffer.
2010-12-11 15:15:51 +11:00
Ronnie Sahlberg
8a6665a092 Licence
Change to LGPL 2.1+ to be compatible with kvm/qemu
2010-12-11 11:47:28 +11:00
Ronnie Sahlberg
709d85c4da Add a COPYING file and updat ehte LGPL boilerplate 2010-12-05 11:11:37 +11:00
Ronnie Sahlberg
098bc5a9a7 Initial import of libiscsi 2010-12-05 08:24:57 +11:00