151 Commits

Author SHA1 Message Date
Anatoliy Glagolev
19d05ab7a7 RTPG support
Implementing support of the Report Target Port Groups command.

Tested on Ubuntu against Pure Storage Flash Array
using designated unit tests and new iscsi-rtpg utility

./iscsi-rtpg  -i iqn.2005-03.org.open-iscsi:6feb2db21ea iscsi://192.168.1.12/iqn.2010-06.com.purestorage:flasharray.4e8d52d82e4b2c0f/1
RTPG retrieved 2 groups
Group 0x0000: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x10 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4a 0x4b 0x4c
0x4d 0x4e 0x4f 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67
0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71]
Group 0x0001: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x20 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7a
0x7b 0x7c 0x7d 0x7e 0x7f 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90 0x91 0x92 0x93 0x94 0x95
0x96 0x97 0x98 0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0 0xa1 0xa2]
2025-07-03 17:20:52 -06:00
zhenwei pi
283e99b322 Introduce helper function scsi_opcode_str
Convert SCSI opcode into string for trouble shooting.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-11-03 12:17:38 +08:00
Bart Van Assche
c412ae0e1d scsi-lowlevel.h: Include <assert.h>
Checking whether static_assert() is defined must happen after <assert.h> has
been included. Hence include <assert.h>.
2021-09-05 20:00:02 -07:00
Ser01x
1c3e2083c9 lib: init version for 8Fh VPD page
The third-party copy (8Fh) VPD page helps to check the capabilities
supported by the copy manager.
2021-07-21 16:28:16 +00:00
David Disseldorp
6eb4b7b6e5 lib: parse Information sense descriptor type
The Information descriptor type is defined in SPC-5 (r17 4.4.2.2) and
may be used to provide the data offset on COMPARE_AND_WRITE miscompare.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:18 +02:00
David Disseldorp
c8992f45b1 test: add support for 0x0A type XCOPY segment descriptors
Type 0x0A segment descriptors provide a 32-bit wide number-of-bytes
field, allowing for much larger copy offloads with a single segment
descriptor.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-03-18 18:59:34 +01:00
Bart Van Assche
a55f11ee68 Improve iser_rx_desc alignment
Align iscsi_header[] and data[] on an 8-byte boundary instead of on a 4-byte
boundary. With this patch applied pahole produces the following output:

struct iser_rx_desc {
        struct iser_hdr    iser_header;                  /*     0    28 */
        char                       pad1[4];              /*    28     4 */
        char                       iscsi_header[48];     /*    32    48 */
        /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
        char                       data[128];            /*    80   128 */
        /* --- cacheline 3 boundary (192 bytes) was 16 bytes ago --- */
        struct ibv_sge     rx_sg;                        /*   208    16 */
        struct ibv_mr *            hdr_mr;               /*   224     8 */
        char                       pad2[24];             /*   232    24 */

        /* size: 256, cachelines: 4, members: 7 */
};

Additionally, this patch fixes the following build errors:

iser.c: In function 'iser_alloc_rx_descriptors':
iser.c:916:11: error: taking address of packed member of 'struct iser_rx_desc' may result in an unaligned pointer value [-Werror=address-of-packed-member]
  916 |   rx_sg = &rx_desc->rx_sg;
      |           ^~~~~~~~~~~~~~~
iser.c: In function 'iser_post_recvm':
iser.c:955:20: error: taking address of packed member of 'struct iser_rx_desc' may result in an unaligned pointer value [-Werror=address-of-packed-member]
  955 |   rx_wr->sg_list = &rx_desc->rx_sg;
      |                    ^~~~~~~~~~~~~~~

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-10-31 14:16:56 -07:00
Khazhismel Kumykov
22648d9dbf add some missing includes
avoids forward referenced enums, and includes standard type defns

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
2019-07-14 12:49:05 +10:00
Tim Crawford
aba0f7da1a Replace WIN32 with _WIN32
Using WIN32 depends on the build environment defining the variable.
_WIN32 is a predefined MSVC macro and is always available.

Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
2017-11-29 10:07:44 -05:00
Ronnie Sahlberg
39001203b7 TESTS: simple support for READDEFECTDATA10/12
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-22 22:43:16 -07:00
Ronnie Sahlberg
a6fc65b4ef Tests: remove the warning if a SSD supports SANITIZE/OVERWRITE
There is technically no reason why a SSD with (assumingly with thin
provisioning) can not support SANITIZE/OVERWRITE instead or or in addition
to the more expected SANITIZE/BLOCK-ERASE so remove the warning for this.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-01 12:35:29 -07:00
David Disseldorp
9aa5b55b41 test/pr: simple PRin REPORT CAPABILITIES test
Check that the Persistent Reserve In REPORT CAPABILITIES response
carries valid LENGTH, ALLOW COMMANDS, and PERSISTENT RESERVATION TYPE
MASK fields.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:19 +02:00
Ronnie Sahlberg
80b81772e2 Add unmarshalling of VPD BLock Limits settings for atomic writes
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-09 06:49:41 -07:00
Ronnie Sahlberg
02fd6217cb Add support for WRITE_ATOMIC_16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-08 10:16:57 -07:00
Ronnie Sahlberg
a6f7c06119 Add support and tests for ExtendedCopy and ReceiveCopyResults
From sushma.gurram@sandisk.com
Add support to libiscsi and tests for these two opcodes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:21 -07:00
Bart Van Assche
8435f9722e lib: Parse sense specific descriptor
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-04-27 19:17:51 -07:00
Ronnie Sahlberg
b6fc366b5c TESTS: Add a test for D_SENSE in the CONTROL mode page
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-04-19 18:20:12 -07:00
Ronnie Sahlberg
7865a8a26e Merge branch 'sgio' 2014-12-21 15:07:40 -08:00
Ronnie Sahlberg
9eabebd78a iscsi.h: remove obsolete scsi_get_data_[in|out]_buffer symbols
These two functions do not exist. Remove them from the header.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-18 05:51:23 -08:00
Ronnie Sahlberg
14461757c4 TESTS: Allow Hardware/Software write protect as valid ASCQ
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-08 06:23:43 -07:00
Bart Van Assche
ded75ae18a Fix WRITE SAME data buffer length handling
From the SPC-4 paragraph about WRITE SAME(10): "The WRITE SAME (10)
command requests that the device server transfer a single logical
block from the Data-Out Buffer [ ... ]". Hence always pass a data
buffer when sending a WRITE SAME(10) command.

Set the NDOB bit in the WRITE SAME(16) command if no data out buffer
is present.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:42:49 -07:00
Bart Van Assche
cfce944b35 test_write*_residuals: Fix overflow tests
RFC 3720 is not clear about whether a target should return SUCCESS
or CHECK CONDITION if SPDTL > EDTL. Hence accept both. See also
Fred Knight, Re: [Ips] Data Out residual overflow/underflow handling,
IETF mailing list archive, 21 September 2012
(http://www.ietf.org/mail-archive/web/ips/current/msg02756.html).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-04 16:04:21 -07:00
Peter Lieven
59e4a07129 Revert "Rewrite and simplify iscsi_iovector_readv_writev"
Since writing headers and payload in a single iov has never been
implementend and after thinking about it several times seems to
be very hairy I would like to revert this change since
the original implementation is in O(1) while the changed one
is in O(n). This results in a complexity of O(n^2) instead of
O(n) for the whole send operation.

This reverts commit 06eab264f6.
2014-07-14 08:05:32 +02:00
Peter Lieven
16165a240f include: add prototypes for scsi_{get,set}_uint64
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-16 09:39:53 +02:00
Ronnie Sahlberg
8aa6d9de8f TESTS: Add a test for COMPARE_AND_WRITE when the data to verify does not match 2013-09-23 21:58:55 -07:00
Ronnie Sahlberg
a9b75b96a3 SCSI: Add definitions for some more 0x29xx ASCQs
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-09-22 17:09:11 -07:00
Sitsofe Wheeler
7692027d6c Fix compilation issues under clang
clang defaults to c99 so remove inline statements
(http://clang.llvm.org/compatibility.html#inline ) on functions shared
across different translation units.
clang's linker doesn't like major numbers over 255 so change how SOREL
is generated in Makefile.am.
2013-09-09 18:04:06 +01:00
Ronnie Sahlberg
6041dcd136 Add a new function to create a scsi_task using an existing CDB 2013-08-04 14:35:58 -07:00
Ronnie Sahlberg
06eab264f6 Rewrite and simplify iscsi_iovector_readv_writev 2013-08-04 14:34:57 -07:00
Ronnie Sahlberg
83a0cd90f9 Add SANITIZE_IN_PROGRESS ASCQ 2013-07-21 09:55:35 -07:00
Ronnie Sahlberg
52a83e91af Add POWER_CONDITION modepage marshalling/unmarshalling 2013-07-20 15:35:38 -07:00
Ronnie Sahlberg
fd38ff4bfc Add MODESENSE6/10 and MODESELECT6/10 support 2013-07-20 14:05:20 -07:00
Ronnie Sahlberg
9e9ca71247 Modesense6 decoding bugs, start preparing for modesense10 decoding 2013-07-08 01:31:03 -07:00
Ronnie Sahlberg
ebb1f06830 Add parameter list length error sense code 2013-07-06 23:35:03 -07:00
Ronnie Sahlberg
a51d706d32 Add invalid field in parameter list sense code 2013-07-06 22:35:36 -07:00
Ronnie Sahlberg
7895fb700c Add MODESELECT6 support
Add support for MODESELECT6 and add marshalling functions for the
mode pages we support so far.
2013-07-06 16:11:17 -07:00
Ronnie Sahlberg
b6e5af558d Unmarshall support for Control modepage 2013-07-05 22:38:45 -07:00
Ronnie Sahlberg
3edd40953e TESTS: SANITIZE, Add tests for WABEREQ/WACEREQ 2013-07-05 14:25:43 -07:00
Bart Van Assche
49d1145a10 Next to BUS RESET, also accept NEXUS LOSS unit attention after login
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-06-08 07:44:43 -07:00
Bart Van Assche
9dce01bbea Fix PERSISTENT RESERVE IN / READ RESERVATION response unmarshalling
The code that verifies the pr_type response must compare only the
lower four bits of byte 21 of the response ("TYPE") and must ignore
the upper four bits ("SCOPE").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-05-29 18:56:00 -07:00
Ronnie Sahlberg
99a74310a2 Block Device Characteristics: Add decode of the rest of this page that was missing 2013-05-27 08:28:26 -07:00
Ronnie Sahlberg
eebd04e613 Add initial support for SANITIZE and a simple test to generate this opcode. 2013-05-25 16:02:02 -07:00
Ronnie Sahlberg
4df179bfd4 TESTS: Add checks for CDB sanity to REPORT SUPPORTED OPCODES
Read all individual opcodes and check that CDB length > 0  and that
CDB[0] Usage Data is 0xFF
2013-05-19 08:18:09 -07:00
Ronnie Sahlberg
709410b1d7 TESTS: Add some REPORT SUPPORTED OPCODES tests
Add a simple test that it works or is not implemented.

Add a RCTD test to verify that with this flag clear we get command descriptors without CTDP set  and with it set we get command descriptors with CTDP set and a timeout descriptor
2013-05-18 13:56:02 -07:00
Ronnie Sahlberg
ce4623b2fb READ SUPPORTED OPCODES. Update the signature to allow setting all of the
parameters to this command.
2013-05-18 12:34:03 -07:00
Ronnie Sahlberg
772d220217 Add a version descriptor 2013-05-11 16:03:23 -07:00
Ronnie Sahlberg
555906e76e Revert "Add SSC to the version descriptors."
This reverts commit 45f5fc2105.

Conflicts:

	include/scsi-lowlevel.h
2013-04-22 18:32:09 -07:00
Ronnie Sahlberg
e640fa3cde missing , broke compile 2013-04-22 18:28:20 -07:00
Ronnie Sahlberg
45f5fc2105 Add SSC to the version descriptors.
I actually have a usb-stick that claims it supports SSC. I stongly doubt it.
2013-04-22 17:44:13 -07:00
Ronnie Sahlberg
91a98d6b92 Add handling of inquiry version descriptors 2013-04-21 14:04:30 -07:00