add more comments

This commit is contained in:
Lei Xue
2016-11-24 21:02:17 +08:00
parent 35765e7f4d
commit f4197d0024
6 changed files with 305 additions and 221 deletions

View File

@@ -43,6 +43,11 @@ script:
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Write10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Read16.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Write16.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Read32.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Write32.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.WriteVerify10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.WriteVerify16.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.WriteVerify32.Simple iscsi://127.0.0.1:3260/${TARGET}/0
- ./utils/iscsi-ls -s iscsi://127.0.0.1:3260/${TARGET}
- ./utils/iscsi-inq iscsi://127.0.0.1:3260/${TARGET}/0
- ./utils/iscsi-readcapacity16 iscsi://127.0.0.1:3260/${TARGET}/0

View File

@@ -65,8 +65,6 @@ You can test this with [open-iscsi](http://www.open-iscsi.com/) or [libiscsi](ht
* Page83(Inquiry) (orzhang, p1)
* Page0 (Inquiry) (orzhang, p1)
* Define Device UUID
* More SCSI flags (carmark, p1)
* Read8,16 (carmark, p1)
* Verify (carmark, p1)
* Support `Target Group` and `Target Port` (p3)
* Refactor (carmark, p1)

View File

@@ -205,13 +205,13 @@ verify:
}
}
glog.Infof("io done %s", string(scb))
return nil
sense:
if err != nil {
glog.Error(err)
return err
}
_ = key
_ = asc
return nil
err = fmt.Errorf("sense data encounter, key: %v, asc: %v", key, asc)
return err
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2015 The GoStor Authors All rights reserved.
Copyright 2016 The GoStor Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -24,13 +24,13 @@ type SCSIPRServiceAction byte
type SCSIPRType byte
var (
/* PERSISTENT_RESERVE_IN service action codes */
// PERSISTENT_RESERVE_IN service action codes
PR_IN_READ_KEYS SCSIPRServiceAction = 0x00
PR_IN_READ_RESERVATION SCSIPRServiceAction = 0x01
PR_IN_REPORT_CAPABILITIES SCSIPRServiceAction = 0x02
PR_IN_READ_FULL_STATUS SCSIPRServiceAction = 0x03
/* PERSISTENT_RESERVE_OUT service action codes */
// PERSISTENT_RESERVE_OUT service action codes
PR_OUT_REGISTER SCSIPRServiceAction = 0x00
PR_OUT_RESERVE SCSIPRServiceAction = 0x01
PR_OUT_RELEASE SCSIPRServiceAction = 0x02
@@ -40,10 +40,10 @@ var (
PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY SCSIPRServiceAction = 0x06
PR_OUT_REGISTER_AND_MOVE SCSIPRServiceAction = 0x07
/* Persistent Reservation scope */
// Persistent Reservation scope
PR_LU_SCOPE byte = 0x00
/* Persistent Reservation Type Mask format */
// Persistent Reservation Type Mask format
PR_TYPE_WRITE_EXCLUSIVE SCSIPRType = 0x01
PR_TYPE_EXCLUSIVE_ACCESS SCSIPRType = 0x03
PR_TYPE_WRITE_EXCLUSIVE_REGONLY SCSIPRType = 0x05
@@ -53,31 +53,185 @@ var (
)
const (
CBD_GROUPID_0 = iota
CBD_GROUPID_1
CBD_GROUPID_2
CBD_GROUPID_3
CBD_GROUPID_4
CBD_GROUPID_5
CBD_GROUPID_6
CBD_GROUPID_7
)
const (
CDB_GROUP0 = 6 /* 6-byte commands */
CDB_GROUP1 = 10 /* 10-byte commands */
CDB_GROUP2 = 10 /* 10-byte commands */
CDB_GROUP3 = 0 /* reserved */
CDB_GROUP4 = 16 /* 16-byte commands */
CDB_GROUP5 = 12 /* 12-byte commands */
CDB_GROUP6 = 0 /* vendor specific */
CDB_GROUP7 = 0 /* vendor specific */
CDB_GROUPID_0 = 6 /* 6-byte commands */
CDB_GROUPID_1 = 10 /* 10-byte commands */
CDB_GROUPID_2 = 10 /* 10-byte commands */
CDB_GROUPID_3 = 0 /* reserved */
CDB_GROUPID_4 = 16 /* 16-byte commands */
CDB_GROUPID_5 = 12 /* 12-byte commands */
CDB_GROUPID_6 = 0 /* vendor specific */
CDB_GROUPID_7 = 0 /* vendor specific */
)
func SCSICDBGroupID(opcode byte) byte {
return ((opcode >> 5) & 0x7)
}
/*
* Protocol Identifier Values
*
* 0 Fibre Channel (FCP-2)
* 1 Parallel SCSI (SPI-5)
* 2 SSA (SSA-S3P)
* 3 IEEE 1394 (SBP-3)
* 4 SCSI Remote Direct Memory Access (SRP)
* 5 iSCSI
* 6 SAS Serial SCSI Protocol (SAS)
* 7 Automation/Drive Interface (ADT)
* 8 AT Attachment Interface (ATA/ATAPI-7)
*/
const (
PIV_FCP = byte(0x00)
PIV_SPI = byte(0x01)
PIV_S3P = byte(0x02)
PIV_SBP = byte(0x03)
PIV_SRP = byte(0x04)
PIV_ISCSI = byte(0x05)
PIV_SAS = byte(0x06)
PIV_ADT = byte(0x07)
PIV_ATA = byte(0x08)
PIV_USB = byte(0x09)
PIV_SOP = byte(0x0A)
)
const (
VERSION_NOT_CLAIM = byte(0x00)
VERSION_WITHDRAW_STANDARD = byte(0x03)
VERSION_WITHDRAW_SPC2 = byte(0x04)
VERSION_WITHDRAW_SPC3 = byte(0x05)
)
/*
* Code Set
*
* 1 - Designator fild contains binary values
* 2 - Designator field contains ASCII printable chars
* 3 - Designaotor field contains UTF-8
*/
const (
INQ_CODE_BIN = byte(1)
INQ_CODE_ASCII = byte(2)
INQ_CODE_UTF8 = byte(3)
)
/*
* Association field
*
* 00b - Associated with Logical Unit
* 01b - Associated with target port
* 10b - Associated with SCSI Target device
* 11b - Reserved
*/
const (
ASS_LU = byte(0x00)
ASS_TGT_PORT = byte(0x01)
ASS_TGT_DEV = byte(0x02)
)
/*
* Table 177 — PERIPHERAL QUALIFIER field
* Qualifier Description
* 000b - A peripheral device having the indicated peripheral
* device type is connected to this logical unit. If the device server is
* unable to determine whether or not a peripheral device is connected,
* then the device server also shall use this peripheral qualifier.
* This peripheral qualifier does not indicate that the peripheral
* device connected to the logical unit is ready for access.
* 001b - A peripheral device having the indicated peripheral device type
* is not connected to this logical unit. However, the device server is capable of
* supporting the indicated peripheral device type on this logical unit.
* 010b - Reserved
* 011b - The device server is not capable of supporting a
* peripheral device on this logical unit. For this peripheral
* qualifier the peripheral device type shall be set to 1Fh. All other peripheral
* device type values are reserved for this peripheral qualifier.
* 100b to 111b Vendor specific
*/
const (
PQ_DEVICE_CONNECTED = byte(0x00 << 5)
PQ_DEVICE_NOT_CONNECT = byte(0x01 << 5)
PQ_RESERVED = byte(0x02 << 5)
PQ_NOT_SUPPORT = byte(0x03 << 5)
)
const (
INQUIRY_SCCS = byte(0x80)
INQUIRY_AAC = byte(0x40)
INQUIRY_TPGS_NO = byte(0x00)
INQUIRY_TPGS_IMPLICIT = byte(0x20)
INQUIRY_TPGS_EXPLICIT = byte(0x10)
INQUIRY_TPGS_BOTH = byte(0x30)
INQUIRY_3PC = byte(0x08)
INQUIRY_Reserved = byte(0x06)
INQUIRY_PROTECT = byte(0x01)
INQUIRY_NORM_ACA = byte(0x20)
INQUIRY_HISUP = byte(0x10)
INQUIRY_STANDARD_FORMAT = byte(0x02)
INQUIRY_ENCSERV = byte(0x40)
INQUIRY_VS0 = byte(0x20)
INQUIRY_MULTIP = byte(0x10)
INQUIRY_ADDR16 = byte(0x01)
INQUIRY_WBUS16 = byte(0x20)
INQUIRY_SYNC = byte(0x10)
INQUIRY_CMDQUE = byte(0x02)
INQUIRY_VS1 = byte(0x01)
INQUIRY_QAS = byte(0x02)
INQUIRY_IUS = byte(0x01)
)
const (
ADDRESS_METHOD_PERIPHERAL_DEVICE = byte(0x00)
ADDRESS_METHOD_FLAT_SPACE = byte(0x01)
ADDRESS_METHOD_LOGICAL_UNIT = byte(0x02)
ADDRESS_METHOD_EXTENDED_LOGICAL_UNIT = byte(0x03)
)
/*
* Designator type - SPC-4 Reference
*
* 0 - Vendor specific - 7.6.3.3
* 1 - T10 vendor ID - 7.6.3.4
* 2 - EUI-64 - 7.6.3.5
* 3 - NAA - 7.6.3.6
* 4 - Relative Target port identifier - 7.6.3.7
* 5 - Target Port group - 7.6.3.8
* 6 - Logical Unit group - 7.6.3.9
* 7 - MD5 logical unit identifier - 7.6.3.10
* 8 - SCSI name string - 7.6.3.11
*/
const (
DESG_VENDOR = iota
DESG_T10
DESG_EUI64
DESG_NAA
DESG_REL_TGT_PORT
DESG_TGT_PORT_GRP
DESG_LU_GRP
DESG_MD5
DESG_SCSI
)
const (
NAA_IEEE_EXTD = byte(0x2)
NAA_LOCAL = byte(0x3)
NAA_IEEE_REGD = byte(0x5)
NAA_IEEE_REGD_EXTD = byte(0x6)
)
const (
SCSIVendorID = "GOSTOR"
SCSIProductID = "GOTGT"
)
/*
* Transfer Length (if any)
* Parameter List Length (if any)
@@ -94,19 +248,19 @@ func SCSICDBBufXLength(scb []byte) (int64, bool) {
group = SCSICDBGroupID(opcode)
switch group {
case CBD_GROUPID_0:
case CDB_GROUPID_0:
length = int64(scb[4])
case CBD_GROUPID_1, CBD_GROUPID_2:
case CDB_GROUPID_2:
length = int64(util.GetUnalignedUint16(scb[7:9]))
case CBD_GROUPID_3:
case CDB_GROUPID_3:
if opcode == 0x7F {
length = int64(scb[7])
} else {
ok = false
}
case CBD_GROUPID_4:
case CDB_GROUPID_4:
length = int64(util.GetUnalignedUint32(scb[6:10]))
case CBD_GROUPID_5:
case CDB_GROUPID_5:
length = int64(util.GetUnalignedUint32(scb[10:14]))
default:
ok = false

View File

@@ -1,5 +1,5 @@
/*
Copyright 2015 The GoStor Authors All rights reserved.
Copyright 2016 The GoStor Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -54,8 +54,8 @@ func (sbc SBCSCSIDeviceProtocol) InitLu(lu *api.SCSILu) error {
lu.Attrs.Readonly = false
lu.Attrs.SWP = false
lu.Attrs.SenseFormat = false
lu.Attrs.VendorID = SCSI_VendorID
lu.Attrs.ProductID = SCSI_ProductID
lu.Attrs.VendorID = SCSIVendorID
lu.Attrs.ProductID = SCSIProductID
lu.Attrs.ProductRev = version.SCSI_VERSION
/*
@@ -216,11 +216,17 @@ func SBCModeSense(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
// The FORMAT UNIT command requests that the device server format the medium into application client
// accessible logical blocks as specified in the number of blocks and block length values received
// in the last mode parameter block descriptor in a MODE SELECT command (see SPC-3). In addition,
// the device server may certify the medium and create control structures for the management of the medium and defects.
// The degree that the medium is altered by this command is vendor-specific.
/*
* SBCFormatUnit Implements SCSI FORMAT UNIT command
* The FORMAT UNIT command requests that the device server format the medium into application client
* accessible logical blocks as specified in the number of blocks and block length values received
* in the last mode parameter block descriptor in a MODE SELECT command (see SPC-3). In addition,
* the device server may certify the medium and create control structures for the management of the medium and defects.
* The degree that the medium is altered by this command is vendor-specific.
*
* Reference : SBC2r16
* 5.2 - FORMAT UNIT
*/
func SBCFormatUnit(host int, cmd *api.SCSICommand) api.SAMStat {
var (
key = ILLEGAL_REQUEST
@@ -266,6 +272,24 @@ func SBCUnmap(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
/*
* SBCReadWrite Implements SCSI READ(10/12/16), WRITE(10/12/16), WRITE AND VERIFY(10/12/16), WRITE SAME(10/12/16)
* The READ command requests that the device server read the specified logical block(s) and transfer them to the data-in buffer.
* The WRITE command requests that the device server transfer the specified logical block(s) from the data-out buffer and write them.
* The WRITE AND VERIFY command requests that the device server transfer the specified logical block(s) from the data-out buffer,
* write them to the medium, and then verify that they are correctly written.
*
* Reference : SBC2r16
* 5.6 - READ (10)
* 5.7 - READ (12)
* 5.8 - READ (16)
* 5.25 - WRITE (10)
* 5.26 - WRITE (12)
* 5.27 - WRITE (16)
* 5.29 - WRITE AND VERIFY (10)
* 5.30 - WRITE AND VERIFY (12)
* 5.31 - WRITE AND VERIFY (16)
*/
func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
var (
key = ILLEGAL_REQUEST
@@ -414,11 +438,17 @@ func SBCRelease(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
// The READ CAPACITY (10) command requests that the device server transfer 8 bytes of parameter data
// describing the capacity and medium format of the direct-access block device to the data-in buffer.
// This command may be processed as if it has a HEAD OF QUEUE task attribute. If the logical unit supports
// protection information, the application client should use the READ CAPACITY (16) command instead of
// the READ CAPACITY (10) command.
/*
* SBCReadCapacity Implements SCSI READ CAPACITY(10) command
* The READ CAPACITY (10) command requests that the device server transfer 8 bytes of parameter data
* describing the capacity and medium format of the direct-access block device to the data-in buffer.
* This command may be processed as if it has a HEAD OF QUEUE task attribute. If the logical unit supports
* protection information, the application client should use the READ CAPACITY (16) command instead of
* the READ CAPACITY (10) command.
*
* Reference : SBC2r16
* 5.10 - READ CAPACITY(10)
*/
func SBCReadCapacity(host int, cmd *api.SCSICommand) api.SAMStat {
var (
scb = cmd.SCB.Bytes()
@@ -465,7 +495,12 @@ sense:
return api.SAMStatCheckCondition
}
// The VERIFY (10) command requests that the device server verify the specified logical block(s) on the medium.
/* SBCVerify Implements SCSI VERIFY(10) command
* The VERIFY (10) command requests that the device server verify the specified logical block(s) on the medium.
*
* Reference : SBC2r16
* 5.20 - VERIFY(10)
*/
func SBCVerify(host int, cmd *api.SCSICommand) api.SAMStat {
var (
key = ILLEGAL_REQUEST
@@ -495,6 +530,14 @@ sense:
return api.SAMStatCheckCondition
}
/*
* SBCReadCapacity16 Implements SCSI READ CAPACITY(16) command
* The READ CAPACITY (16) command requests that the device server transfer parameter data
* describing the capacity and medium format of the direct-access block device to the data-in buffer.
*
* Reference : SBC2r16
* 5.11 - READ CAPACITY(16)
*/
func SBCReadCapacity16(host int, cmd *api.SCSICommand) api.SAMStat {
var (
data = &bytes.Buffer{}
@@ -526,9 +569,16 @@ func SBCServiceAction(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
// The SYNCHRONIZE CACHE (10) command requests that the device server ensure that
// the specified logical blocks have their most recent data values recorded in
// non-volatile cache and/or on the medium, based on the SYNC_NV bit.
/*
* SBCSyncCache Implements SCSI SYNCHRONIZE CACHE(10) and SYNCHRONIZE CACHE(16) command
* The SYNCHRONIZE CACHE command requests that the device server ensure that
* the specified logical blocks have their most recent data values recorded in
* non-volatile cache and/or on the medium, based on the SYNC_NV bit.
*
* Reference : SBC2r16
* 5.18 - SYNCHRONIZE CACHE (10)
* 5.19 - SYNCHRONIZE CACHE (16)
*/
func SBCSyncCache(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}

View File

@@ -27,171 +27,6 @@ import (
"github.com/gostor/gotgt/pkg/util"
)
/*
* Protocol Identifier Values
*
* 0 Fibre Channel (FCP-2)
* 1 Parallel SCSI (SPI-5)
* 2 SSA (SSA-S3P)
* 3 IEEE 1394 (SBP-3)
* 4 SCSI Remote Direct Memory Access (SRP)
* 5 iSCSI
* 6 SAS Serial SCSI Protocol (SAS)
* 7 Automation/Drive Interface (ADT)
* 8 AT Attachment Interface (ATA/ATAPI-7)
*/
const (
PIV_FCP = byte(0x00)
PIV_SPI = byte(0x01)
PIV_S3P = byte(0x02)
PIV_SBP = byte(0x03)
PIV_SRP = byte(0x04)
PIV_ISCSI = byte(0x05)
PIV_SAS = byte(0x06)
PIV_ADT = byte(0x07)
PIV_ATA = byte(0x08)
PIV_USB = byte(0x09)
PIV_SOP = byte(0x0A)
)
const (
VERSION_NOT_CLAIM = byte(0x00)
VERSION_WITHDRAW_STANDARD = byte(0x03)
VERSION_WITHDRAW_SPC2 = byte(0x04)
VERSION_WITHDRAW_SPC3 = byte(0x05)
)
/*
* Code Set
*
* 1 - Designator fild contains binary values
* 2 - Designator field contains ASCII printable chars
* 3 - Designaotor field contains UTF-8
*/
const (
INQ_CODE_BIN = byte(1)
INQ_CODE_ASCII = byte(2)
INQ_CODE_UTF8 = byte(3)
)
/*
* Association field
*
* 00b - Associated with Logical Unit
* 01b - Associated with target port
* 10b - Associated with SCSI Target device
* 11b - Reserved
*/
const (
ASS_LU = byte(0x00)
ASS_TGT_PORT = byte(0x01)
ASS_TGT_DEV = byte(0x02)
)
/*
* Table 177 — PERIPHERAL QUALIFIER field
* Qualifier Description
* 000b - A peripheral device having the indicated peripheral
* device type is connected to this logical unit. If the device server is
* unable to determine whether or not a peripheral device is connected,
* then the device server also shall use this peripheral qualifier.
* This peripheral qualifier does not indicate that the peripheral
* device connected to the logical unit is ready for access.
* 001b - A peripheral device having the indicated peripheral device type
* is not connected to this logical unit. However, the device server is capable of
* supporting the indicated peripheral device type on this logical unit.
* 010b - Reserved
* 011b - The device server is not capable of supporting a
* peripheral device on this logical unit. For this peripheral
* qualifier the peripheral device type shall be set to 1Fh. All other peripheral
* device type values are reserved for this peripheral qualifier.
* 100b to 111b Vendor specific
*/
const (
PQ_DEVICE_CONNECTED = byte(0x00 << 5)
PQ_DEVICE_NOT_CONNECT = byte(0x01 << 5)
PQ_RESERVED = byte(0x02 << 5)
PQ_NOT_SUPPORT = byte(0x03 << 5)
)
const (
INQUIRY_SCCS = byte(0x80)
INQUIRY_AAC = byte(0x40)
INQUIRY_TPGS_NO = byte(0x00)
INQUIRY_TPGS_IMPLICIT = byte(0x10)
INQUIRY_TPGS_EXPLICIT = byte(0x20)
INQUIRY_TPGS_BOTH = byte(0x30)
INQUIRY_3PC = byte(0x08)
INQUIRY_Reserved = byte(0x06)
INQUIRY_PROTECT = byte(0x01)
INQUIRY_NORM_ACA = byte(0x20)
INQUIRY_HISUP = byte(0x10)
INQUIRY_STANDARD_FORMAT = byte(0x02)
INQUIRY_ENCSERV = byte(0x40)
INQUIRY_VS0 = byte(0x20)
INQUIRY_MULTIP = byte(0x10)
INQUIRY_ADDR16 = byte(0x01)
INQUIRY_WBUS16 = byte(0x20)
INQUIRY_SYNC = byte(0x10)
INQUIRY_CMDQUE = byte(0x02)
INQUIRY_VS1 = byte(0x01)
INQUIRY_QAS = byte(0x02)
INQUIRY_IUS = byte(0x01)
)
const (
ADDRESS_METHOD_PERIPHERAL_DEVICE = byte(0x00)
ADDRESS_METHOD_FLAT_SPACE = byte(0x01)
ADDRESS_METHOD_LOGICAL_UNIT = byte(0x02)
ADDRESS_METHOD_EXTENDED_LOGICAL_UNIT = byte(0x03)
)
/*
* Designator type - SPC-4 Reference
*
* 0 - Vendor specific - 7.6.3.3
* 1 - T10 vendor ID - 7.6.3.4
* 2 - EUI-64 - 7.6.3.5
* 3 - NAA - 7.6.3.6
* 4 - Relative Target port identifier - 7.6.3.7
* 5 - Target Port group - 7.6.3.8
* 6 - Logical Unit group - 7.6.3.9
* 7 - MD5 logical unit identifier - 7.6.3.10
* 8 - SCSI name string - 7.6.3.11
*/
const (
DESG_VENDOR = iota
DESG_T10
DESG_EUI64
DESG_NAA
DESG_REL_TGT_PORT
DESG_TGT_PORT_GRP
DESG_LU_GRP
DESG_MD5
DESG_SCSI
)
const (
NAA_IEEE_EXTD = byte(0x2)
NAA_LOCAL = byte(0x3)
NAA_IEEE_REGD = byte(0x5)
NAA_IEEE_REGD_EXTD = byte(0x6)
)
const (
SCSI_VendorID = "GOSTOR"
SCSI_ProductID = "GOTGT"
)
func SPCIllegalOp(host int, cmd *api.SCSICommand) api.SAMStat {
BuildSenseData(cmd, ILLEGAL_REQUEST, ASC_INVALID_FIELD_IN_CDB)
return api.SAMStatCheckCondition
@@ -360,6 +195,13 @@ func InquiryPage0x83(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16) {
return buf, pageLength
}
/*
* SPCInquiry Implements SCSI INQUIRY command
* The INQUIRY command requests the device server to return information regarding the logical unit and SCSI target device.
*
* Reference : SPC4r11
* 6.6 - INQUIRY
*/
func SPCInquiry(host int, cmd *api.SCSICommand) api.SAMStat {
var (
allocationLength uint16
@@ -478,6 +320,14 @@ sense:
return api.SAMStatCheckCondition
}
/*
* SPCReportLuns Implements SCSI REPORT LUNS command
* The REPORT LUNS command requests the device server to return the peripheral Device
* logical unit inventory accessible to the I_T nexus.
*
* Reference : SPC4r11
* 6.33 - REPORT LUNS
*/
func SPCReportLuns(host int, cmd *api.SCSICommand) api.SAMStat {
var (
remainLength uint32
@@ -576,6 +426,13 @@ func SPCStartStop(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
/*
* SPCTestUnit Implements SCSI TEST UNIT READY command
* The TEST UNIT READY command requests the device server to indicate whether the logical unit is ready.
*
* Reference : SPC4r11
* 6.47 - TEST UNIT READY
*/
func SPCTestUnit(host int, cmd *api.SCSICommand) api.SAMStat {
/*
if err := deviceReserve(cmd); err != nil {
@@ -603,10 +460,15 @@ func SPCPreventAllowMediaRemoval(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
// SPCModeSense Implement SCSI op MODE SENSE(6) and MODE SENSE(10)
// Reference : SPC4r11
// 6.11 - MODE SENSE(6)
// 6.12 - MODE SENSE(10)
/*
* SPCModeSense Implement SCSI MODE SENSE(6) and MODE SENSE(10) command
* The MODE SENSE command requests the device server to return the specified medium,
* logical unit, or peripheral device parameters.
*
* Reference : SPC4r11
* 6.11 - MODE SENSE(6)
* 6.12 - MODE SENSE(10)
*/
func SPCModeSense(host int, cmd *api.SCSICommand) api.SAMStat {
var (
scb = cmd.SCB.Bytes()
@@ -637,6 +499,14 @@ sense:
return api.SAMStatCheckCondition
}
/*
* SPCSendDiagnostics Implements SCSI SEND DIAGNOSTIC command
* The SEND DIAGNOSTIC command requests the device server to perform diagnostic operations
* on the SCSI target device, on the logical unit, or on both.
*
* Reference : SPC4r11
* 6.42 - SEND DIAGNOSTIC
*/
func SPCSendDiagnostics(host int, cmd *api.SCSICommand) api.SAMStat {
// we only support SELF-TEST==1
if cmd.SCB.Bytes()[1]&0x04 == 0 {
@@ -826,6 +696,13 @@ func SPCPRRegisterAndMove(host int, cmd *api.SCSICommand) api.SAMStat {
return api.SAMStatGood
}
/*
* SPCRequestSense Implements SCSI REQUEST SENSE command
* The REQUEST SENSE command requests the device server to return parameter data that contains sense data.
*
* Reference : SPC4r11
* 6.39 - REQUEST SENSE
*/
func SPCRequestSense(host int, cmd *api.SCSICommand) api.SAMStat {
var (
allocationLength uint32
@@ -844,7 +721,7 @@ func SPCRequestSense(host int, cmd *api.SCSICommand) api.SAMStat {
actualLength = allocationLength
}
if cmd.SenseBuffer != nil {
data.Write(cmd.SenseBuffer.Bytes()[0:actualLength])
data.Write(cmd.SenseBuffer.Bytes()[:actualLength])
}
cmd.InSDBBuffer.Resid = int32(actualLength)
cmd.InSDBBuffer.Buffer = data