Merge pull request #4 from orzhang/scsi_cmdgroup

Scsi cmdgroup
This commit is contained in:
Lei Xue
2015-12-16 07:18:39 +08:00
7 changed files with 66 additions and 29 deletions

View File

@@ -34,7 +34,7 @@ type BackingStore interface {
type BackingStoreFunc func() (BackingStore, error)
var registeredPlugins = map[name](BackingStoreFunc){}
var registeredPlugins = map[string](BackingStoreFunc){}
func RegisterBackingStore(name string, f BackingStoreFunc) {
registeredPlugins[name] = f

View File

@@ -162,6 +162,28 @@ const (
SCSIDataBidirection
)
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 */
)
type SCSIDataBuffer struct {
Buffer uint64
Length uint64
@@ -190,3 +212,7 @@ type SCSICommand struct {
SenseBuffer []byte
SenseLength int
}
func SCSICDBGroupID(opcode byte) byte {
return ((opcode >> 5) & 0x7)
}

View File

@@ -17,7 +17,7 @@ limitations under the License.
// Target Driver Interface
package scsi
var SCSITargetDriverState int
type SCSITargetDriverState int
const (
// just registered
@@ -51,7 +51,9 @@ type SCSITargetDriverOps interface {
CommandNotify(nid uint64, result int, cmd *SCSICommand) error
}
var fakeSCSITargetDriver SCSITargetDriver
type fakeSCSITargetDriver struct {
SCSITargetDriver
}
func (fake *fakeSCSITargetDriver) Init() error {
return nil

View File

@@ -63,7 +63,6 @@ var (
ASC_LOGICAL_UNIT_NOT_CONFIG SCSISubError = 0x3e00
/* Key 3: Medium Errors */
ASC_WRITE_ERROR SCSISubError = 0x0c00
ASC_UNRECOVERED_READ SCSISubError = 0x1100
ASC_RECORDED_ENTITY_NOT_FOUND SCSISubError = 0x1400
ASC_UNKNOWN_FORMAT SCSISubError = 0x3001

View File

@@ -39,8 +39,8 @@ func (sbc *SBCSCSIDeviceProtocol) OfflineLu(lu *SCSILu) error {
func NewSBCDevice() (SBCSCSIDeviceProtocol, error) {
var sbc = SBCSCSIDeviceProtocol{
Type: TYPE_DISK,
SCSIDeviceOps: make([]SCSIDeviceOperation, 0xff),
BaseSCSIDeviceProtocol{Type: TYPE_DISK,
SCSIDeviceOps: make([]SCSIDeviceOperation, 256)},
}
for i := 0; i <= 256; i++ {
sbc.SCSIDeviceOps = append(sbc.SCSIDeviceOps, NewSCSIDeviceOperation(SPCIllegalOp, nil, 0))
@@ -94,6 +94,8 @@ func NewSBCDevice() (SBCSCSIDeviceProtocol, error) {
sbc.SCSIDeviceOps[WRITE_12] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_WE_FA|PR_EA_FA|PR_WE_FA|PR_WE_FN)
sbc.SCSIDeviceOps[WRITE_VERIFY_12] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
sbc.SCSIDeviceOps[VERIFY_12] = NewSCSIDeviceOperation(SBCVerify, nil, PR_EA_FA|PR_EA_FN)
return sbc, nil
}
func SBCModeSelect(host int, cmd *SCSICommand) error {

View File

@@ -30,18 +30,17 @@ package scsi
* 7 Automation/Drive Interface (ADT)
* 8 AT Attachment Interface (ATA/ATAPI-7)
*/
type ProtocolIdentifier int
var (
PIV_FCP ProtocolIdentifier = iota
PIV_SPI ProtocolIdentifier
PIV_S3P ProtocolIdentifier
PIV_SBP ProtocolIdentifier
PIV_SRP ProtocolIdentifier
PIV_ISCSI ProtocolIdentifier
PIV_SAS ProtocolIdentifier
PIV_ADT ProtocolIdentifier
PIV_ATA ProtocolIdentifier
const (
PIV_FCP = iota
PIV_SPI
PIV_S3P
PIV_SBP
PIV_SRP
PIV_ISCSI
PIV_SAS
PIV_ADT
PIV_ATA
)
/*
@@ -88,18 +87,17 @@ var (
* 7 - MD5 logical unit identifier - 7.6.3.10
* 8 - SCSI name string - 7.6.3.11
*/
type DesignatorType int
var (
DESG_VENDOR DesignatorType = iota
DESG_T10 DesignatorType
DESG_EUI64 DesignatorType
DESG_NAA DesignatorType
DESG_REL_TGT_PORT DesignatorType
DESG_TGT_PORT_GRP DesignatorType
DESG_LU_GRP DesignatorType
DESG_MD5 DesignatorType
DESG_SCSI DesignatorType
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
)
func SPCIllegalOp(host int, cmd *SCSICommand) error {
@@ -175,4 +173,5 @@ func SPCRequestSense(host int, cmd *SCSICommand) error {
}
func SPCSendDiagnostics(host int, cmd *SCSICommand) error {
return nil
}

View File

@@ -16,13 +16,22 @@ limitations under the License.
package scsi
var SCSITargetState int
type SCSITargetState int
var (
TargetOnline SCSITargetState = 1
TargetReady SCSITargetState = 2
)
const (
PR_SPECIAL = (1 << 5)
PR_WE_FA = (1 << 4)
PR_EA_FA = (1 << 3)
PR_RR_FR = (1 << 2)
PR_WE_FN = (1 << 1)
PR_EA_FN = (1 << 0)
)
type SCSITarget struct {
Name string
TID int