general framework for SBC/SPC
This commit is contained in:
131
pkg/scsi/sbc.go
131
pkg/scsi/sbc.go
@@ -16,3 +16,134 @@ limitations under the License.
|
|||||||
|
|
||||||
// SCSI block command processing
|
// SCSI block command processing
|
||||||
package scsi
|
package scsi
|
||||||
|
|
||||||
|
type SBCSCSIDeviceProtocol struct {
|
||||||
|
BaseSCSIDeviceProtocol
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sbc *SBCSCSIDeviceProtocol) InitLu(lu *SCSILu) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (sbc *SBCSCSIDeviceProtocol) ExitLu(lu *SCSILu) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (sbc *SBCSCSIDeviceProtocol) ConfigLu(lu *SCSILu) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (sbc *SBCSCSIDeviceProtocol) OnlineLu(lu *SCSILu) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (sbc *SBCSCSIDeviceProtocol) OfflineLu(lu *SCSILu) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSBCDevice() (SBCSCSIDeviceProtocol, error) {
|
||||||
|
var sbc = SBCSCSIDeviceProtocol{
|
||||||
|
Type: TYPE_DISK,
|
||||||
|
SCSIDeviceOps: make([]SCSIDeviceOperation, 0xff),
|
||||||
|
}
|
||||||
|
for i := 0; i <= 256; i++ {
|
||||||
|
sbc.SCSIDeviceOps = append(sbc.SCSIDeviceOps, NewSCSIDeviceOperation(SPCIllegalOp, nil, 0))
|
||||||
|
}
|
||||||
|
sbc.SCSIDeviceOps[TEST_UNIT_READY] = NewSCSIDeviceOperation(SPCTestUnit, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[REQUEST_SENSE] = NewSCSIDeviceOperation(SPCRequestSense, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[FORMAT_UNIT] = NewSCSIDeviceOperation(SBCFormatUnit, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[READ_6] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_6] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN|PR_WE_FA|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[INQUIRY] = NewSCSIDeviceOperation(SPCInquiry, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[MODE_SELECT] = NewSCSIDeviceOperation(SBCModeSelect, nil, PR_WE_FA|PR_EA_FA|PR_WE_FN|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[RESERVE] = NewSCSIDeviceOperation(SBCReserve, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[RELEASE] = NewSCSIDeviceOperation(SBCRelease, nil, 0)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[MODE_SENSE] = NewSCSIDeviceOperation(SBCModeSense, nil, PR_WE_FA|PR_EA_FA|PR_EA_FN|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[START_STOP] = NewSCSIDeviceOperation(SPCStartStop, nil, PR_SPECIAL)
|
||||||
|
sbc.SCSIDeviceOps[SEND_DIAGNOSTIC] = NewSCSIDeviceOperation(SPCSendDiagnostics, nil, 0)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[ALLOW_MEDIUM_REMOVAL] = NewSCSIDeviceOperation(SPCPreventAllowMediaRemoval, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[READ_CAPACITY] = NewSCSIDeviceOperation(SBCReadCapacity, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[READ_10] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_10] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_WE_FA|PR_EA_FA|PR_EA_FN|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_VERIFY] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[VERIFY_10] = NewSCSIDeviceOperation(SBCVerify, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[PRE_FETCH_10] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[SYNCHRONIZE_CACHE] = NewSCSIDeviceOperation(SBCSyncCache, nil, PR_WE_FA|PR_EA_FA|PR_WE_FN|PR_EA_FN)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[WRITE_SAME] = NewSCSIDeviceOperation(SBCReadWrite, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[UNMAP] = NewSCSIDeviceOperation(SBCUnmap, nil, 0)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[MODE_SELECT_10] = NewSCSIDeviceOperation(SBCModeSelect, nil, PR_WE_FA|PR_EA_FA|PR_EA_FN|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[MODE_SENSE_10] = NewSCSIDeviceOperation(SBCModeSense, nil, PR_WE_FA|PR_WE_FN|PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[PERSISTENT_RESERVE_IN] = NewSCSIDeviceOperation(SPCServiceAction, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[PERSISTENT_RESERVE_OUT] = NewSCSIDeviceOperation(SPCServiceAction, nil, 0)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[READ_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN|PR_WE_FA|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[ORWRITE_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_VERIFY_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[VERIFY_16] = NewSCSIDeviceOperation(SBCVerify, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[PRE_FETCH_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
sbc.SCSIDeviceOps[SYNCHRONIZE_CACHE_16] = NewSCSIDeviceOperation(SBCSyncCache, nil, PR_EA_FA|PR_EA_FN|PR_WE_FA|PR_WE_FN)
|
||||||
|
sbc.SCSIDeviceOps[WRITE_SAME_16] = NewSCSIDeviceOperation(SBCReadWrite, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[SERVICE_ACTION_IN] = NewSCSIDeviceOperation(SPCServiceAction, nil, 0)
|
||||||
|
|
||||||
|
sbc.SCSIDeviceOps[REPORT_LUNS] = NewSCSIDeviceOperation(SPCReportLuns, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[EXCHANGE_MEDIUM] = NewSCSIDeviceOperation(SPCServiceAction, nil, 0)
|
||||||
|
sbc.SCSIDeviceOps[READ_12] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN)
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCModeSelect(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCModeSense(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCFormatUnit(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCUnmap(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCReadWrite(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCReserve(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCRelease(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCReadCapacity(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCVerify(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCReadCapacity16(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCGetLbaStatus(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCServiceAction(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SBCSyncCache(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,3 +58,37 @@ var (
|
|||||||
|
|
||||||
TYPE_PT SCSIDeviceType = 0xff
|
TYPE_PT SCSIDeviceType = 0xff
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CommandFunc func(host int, cmd *SCSICommand) error
|
||||||
|
|
||||||
|
type SCSIServiceAction struct {
|
||||||
|
ServiceAction uint32
|
||||||
|
CommandPerformFunc CommandFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
type SCSIDeviceOperation struct {
|
||||||
|
CommandPerformFunc CommandFunc
|
||||||
|
ServiceAction *SCSIServiceAction
|
||||||
|
PRConflictBits uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseSCSIDeviceProtocol struct {
|
||||||
|
Type SCSIDeviceType
|
||||||
|
SCSIDeviceOps []SCSIDeviceOperation
|
||||||
|
}
|
||||||
|
|
||||||
|
type SCSIDeviceProtocol interface {
|
||||||
|
InitLu(lu *SCSILu) error
|
||||||
|
ExitLu(lu *SCSILu) error
|
||||||
|
ConfigLu(lu *SCSILu) error
|
||||||
|
OnlineLu(lu *SCSILu) error
|
||||||
|
OfflineLu(lu *SCSILu) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSCSIDeviceOperation(fn CommandFunc, sa *SCSIServiceAction, pr uint8) SCSIDeviceOperation {
|
||||||
|
return SCSIDeviceOperation{
|
||||||
|
CommandPerformFunc: fn,
|
||||||
|
ServiceAction: sa,
|
||||||
|
PRConflictBits: pr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -101,3 +101,78 @@ var (
|
|||||||
DESG_MD5 DesignatorType
|
DESG_MD5 DesignatorType
|
||||||
DESG_SCSI DesignatorType
|
DESG_SCSI DesignatorType
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func SPCIllegalOp(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCInquiry(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCReportLuns(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCStartStop(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCTestUnit(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPreventAllowMediaRemoval(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCModeSense(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCServiceAction(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRReadKeys(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRReadReservation(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRReportCapabilities(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRRegister(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRReserve(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRRelease(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRClear(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRPreempt(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCPRRegisterAndMove(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCRequestSense(host int, cmd *SCSICommand) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SPCSendDiagnostics(host int, cmd *SCSICommand) error {
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user