Documentation ¶
Overview ¶
iSCSI Target Driver
Index ¶
- Constants
- Variables
- func GeniSCSIITNexusID(sess *ISCSISession) string
- func MakeSSID(ISID uint64, TPGT uint16) uint64
- func NewISCSITargetDriver(base *scsi.SCSITargetService) (scsi.SCSITargetDriver, error)
- func ParseSSID(SSID uint64) (uint64, uint16)
- func ParseUint(data []byte) uint64
- type AuthMethod
- type ISCSICommand
- type ISCSIDiscoveryMethod
- type ISCSIRedirectInfo
- type ISCSISession
- type ISCSISessionParam
- type ISCSISessionParamList
- type ISCSITarget
- func (tgt *ISCSITarget) CommandNotify(nid uint64, result int, cmd *api.SCSICommand) error
- func (tgt *ISCSITarget) CreateLu(lu *api.SCSILu) error
- func (tgt *ISCSITarget) CreatePortal(name string) error
- func (tgt *ISCSITarget) CreateTarget(target *api.SCSITarget) error
- func (tgt *ISCSITarget) DestroyPortal(name string) error
- func (tgt *ISCSITarget) DestroyTarget(target *api.SCSITarget) error
- func (tgt *ISCSITarget) Exit() error
- func (tgt *ISCSITarget) FindTPG(portal string) (uint16, error)
- func (tgt *ISCSITarget) GetLu(lun uint8) (uint64, error)
- func (tgt *ISCSITarget) Init() error
- type ISCSITargetDriver
- func (s *ISCSITargetDriver) AddiSCSIPortal(tgtName string, tpgt uint16, portal string) error
- func (s *ISCSITargetDriver) AllocTSIH() uint16
- func (s *ISCSITargetDriver) BindISCSISession(conn *iscsiConnection) error
- func (s *ISCSITargetDriver) HasPortal(tgtName string, tpgt uint16, portal string) bool
- func (s *ISCSITargetDriver) LookupISCSISession(tgtName string, iniName string, isid uint64, tsih uint16, tpgt uint16) *ISCSISession
- func (s *ISCSITargetDriver) NewISCSISession(conn *iscsiConnection) (*ISCSISession, error)
- func (s *ISCSITargetDriver) NewTarget(tgtName string, configInfo *config.Config) error
- func (s *ISCSITargetDriver) ReInstatement(existSess *ISCSISession, conn *iscsiConnection) (*ISCSISession, error)
- func (s *ISCSITargetDriver) ReleaseTSIH(tsih uint16)
- func (s *ISCSITargetDriver) Run() error
- func (s *ISCSITargetDriver) UnBindISCSISession(sess *ISCSISession)
- type KeyConvFunc
- type KeyInConvFunc
- type OpCode
Constants ¶
const ( AuthNone = iota AuthChap )
const ( // Defined on the initiator. OpNoopOut OpCode = 0x00 OpSCSICmd = 0x01 OpSCSITaskReq = 0x02 OpLoginReq = 0x03 OpTextReq = 0x04 OpSCSIOut = 0x05 OpLogoutReq = 0x06 OpSNACKReq = 0x10 // Defined on the target. OpNoopIn OpCode = 0x20 OpSCSIResp = 0x21 OpSCSITaskResp = 0x22 OpLoginResp = 0x23 OpTextResp = 0x24 OpSCSIIn = 0x25 OpLogoutResp = 0x26 OpReady = 0x31 OpAsync = 0x32 OpReject = 0x3f )
const ( CONN_STATE_FREE = 0 CONN_STATE_SECURITY = 1 CONN_STATE_SECURITY_AUTH = 2 CONN_STATE_SECURITY_DONE = 3 CONN_STATE_SECURITY_LOGIN = 4 CONN_STATE_SECURITY_FULL = 5 CONN_STATE_LOGIN = 6 CONN_STATE_LOGIN_FULL = 7 CONN_STATE_FULL = 8 CONN_STATE_KERNEL = 9 CONN_STATE_CLOSE = 10 CONN_STATE_EXIT = 11 CONN_STATE_SCSI = 12 CONN_STATE_INIT = 13 CONN_STATE_START = 14 CONN_STATE_READY = 15 )
const ( ISCSI_MAX_TSIH = uint16(0xffff) ISCSI_UNSPEC_TSIH = uint16(0) )
const ( IOSTATE_FREE = iota IOSTATE_RX_BHS IOSTATE_RX_INIT_AHS IOSTATE_RX_AHS IOSTATE_RX_INIT_HDIGEST IOSTATE_RX_HDIGEST IOSTATE_RX_CHECK_HDIGEST IOSTATE_RX_INIT_DATA IOSTATE_RX_DATA IOSTATE_RX_INIT_DDIGEST IOSTATE_RX_DDIGEST IOSTATE_RX_CHECK_DDIGEST IOSTATE_RX_END IOSTATE_TX_BHS IOSTATE_TX_INIT_AHS IOSTATE_TX_AHS IOSTATE_TX_INIT_HDIGEST IOSTATE_TX_HDIGEST IOSTATE_TX_INIT_DATA IOSTATE_TX_DATA IOSTATE_TX_INIT_DDIGEST IOSTATE_TX_DDIGEST IOSTATE_TX_END )
const ( SecurityNegotiation iSCSILoginStage = 0 LoginOperationalNegotiation = 1 FullFeaturePhase = 3 )
const ( MAX_QUEUE_CMD_MIN = 1 MAX_QUEUE_CMD_DEF = 128 MAX_QUEUE_CMD_MAX = 512 )
const ( ISCSI_PARAM_MAX_RECV_DLENGTH = iota ISCSI_PARAM_HDRDGST_EN ISCSI_PARAM_DATADGST_EN ISCSI_PARAM_INITIAL_R2T_EN ISCSI_PARAM_MAX_R2T ISCSI_PARAM_IMM_DATA_EN ISCSI_PARAM_FIRST_BURST ISCSI_PARAM_MAX_BURST ISCSI_PARAM_PDU_INORDER_EN ISCSI_PARAM_DATASEQ_INORDER_EN ISCSI_PARAM_ERL ISCSI_PARAM_IFMARKER_EN ISCSI_PARAM_OFMARKER_EN ISCSI_PARAM_DEFAULTTIME2WAIT ISCSI_PARAM_DEFAULTTIME2RETAIN ISCSI_PARAM_OFMARKINT ISCSI_PARAM_IFMARKINT ISCSI_PARAM_MAXCONNECTIONS /* iSCSI Extensions for RDMA (RFC5046) */ ISCSI_PARAM_RDMA_EXTENSIONS ISCSI_PARAM_TARGET_RDSL ISCSI_PARAM_INITIATOR_RDSL ISCSI_PARAM_MAX_OUTST_PDU /* "local" parmas, never sent to the initiator */ ISCSI_PARAM_FIRST_LOCAL ISCSI_PARAM_MAX_XMIT_DLENGTH = ISCSI_PARAM_FIRST_LOCAL ISCSI_PARAM_MAX_QUEUE_CMD /* must always be last */ ISCSI_PARAM_MAX )
const DataPadding = 4
Variables ¶
var ( DATAIN byte = 0x01 DATAOUT byte = 0x10 )
var ( SESSION_NORMAL int = 0 SESSION_DISCOVERY int = 1 )
var BHS_SIZE = 48
var DIGEST_ALL uint = DIGEST_NONE | DIGEST_CRC32C
var DIGEST_CRC32C uint = 1 << 1
var DIGEST_NONE uint = 1 << 0
var ISCSI_OPCODE_MASK = 0x3F
Functions ¶
func GeniSCSIITNexusID ¶
func GeniSCSIITNexusID(sess *ISCSISession) string
* iSCSI I_T nexus identifer = (iSCSI Initiator Name + 'i' + ISID, iSCSI Target Name + 't' + Portal Group Tag)
func MakeSSID ¶
* RFC 3720 iSCSI SSID = ISID , TPGT * ISID is an 6 bytes number, TPGT is an 2 bytes number * We combime ISID and TPGT together to be SSID
func NewISCSITargetDriver ¶
func NewISCSITargetDriver(base *scsi.SCSITargetService) (scsi.SCSITargetDriver, error)
Types ¶
type AuthMethod ¶
type AuthMethod int
type ISCSICommand ¶
type ISCSICommand struct { OpCode OpCode RawHeader []byte DataLen int RawData []byte Final bool Immediate bool TaskTag uint32 ExpCmdSN, MaxCmdSN uint32 AHSLen int // Connection ID. ConnID uint16 // Command serial number. CmdSN uint32 // Expected status serial. ExpStatSN uint32 Read, Write bool LUN [8]uint8 // Transit bit. Transit bool // Continue bit. Cont bool // Current Stage, Next Stage. CSG, NSG iSCSILoginStage // Initiator part of the SSID. ISID uint64 // Target-assigned Session Identifying Handle. TSIH uint16 // Status serial number. StatSN uint32 // For login response. StatusClass uint8 StatusDetail uint8 // SCSI commands ExpectedDataLen uint32 CDB []byte Status byte SCSIResponse byte // R2T R2TSN uint32 DesiredLength uint32 // Data-In/Out HasStatus bool DataSN uint32 BufferOffset uint32 }
func (*ISCSICommand) Bytes ¶
func (cmd *ISCSICommand) Bytes() []byte
func (*ISCSICommand) String ¶
func (m *ISCSICommand) String() string
type ISCSIDiscoveryMethod ¶
type ISCSIDiscoveryMethod string
var ( ISCSIDiscoverySendTargets ISCSIDiscoveryMethod = "sendtargets" ISCSIDiscoveryStaticConfig ISCSIDiscoveryMethod = "static" ISCSIDiscoveryISNS ISCSIDiscoveryMethod = "isns" )
type ISCSIRedirectInfo ¶
type ISCSISession ¶
type ISCSISession struct { Refcount int Initiator string InitiatorAlias string Target *ISCSITarget ISID uint64 TSIH uint16 TPGT uint16 SessionType int ITNexus *api.ITNexus ExpCmdSN uint32 MaxCmdSN uint32 // currently, this is only one connection per session Connections map[uint16]*iscsiConnection ConnectionsRWMutex sync.RWMutex Commands []*ISCSICommand PendingTasks taskQueue MaxQueueCommand uint32 SessionParam ISCSISessionParamList Info string Rdma int }
Session is an iSCSI session.
func (*ISCSISession) LookupConnection ¶
func (sess *ISCSISession) LookupConnection(cid uint16) *iscsiConnection
type ISCSISessionParam ¶
type ISCSISessionParamList ¶
type ISCSISessionParamList []ISCSISessionParam
func (ISCSISessionParamList) Len ¶
func (list ISCSISessionParamList) Len() int
func (ISCSISessionParamList) Less ¶
func (list ISCSISessionParamList) Less(i, j int) bool
func (ISCSISessionParamList) Swap ¶
func (list ISCSISessionParamList) Swap(i, j int)
type ISCSITarget ¶
type ISCSITarget struct { api.SCSITarget api.SCSITargetDriverCommon // TPGT number is the key TPGTs map[uint16]*iSCSITPGT // TSIH is the key Sessions map[uint16]*ISCSISession SessionsRWMutex sync.RWMutex Alias string MaxSessions int RedirectInfo ISCSIRedirectInfo Rdma int NopInterval int NopCount int }
func (*ISCSITarget) CommandNotify ¶
func (tgt *ISCSITarget) CommandNotify(nid uint64, result int, cmd *api.SCSICommand) error
func (*ISCSITarget) CreatePortal ¶
func (tgt *ISCSITarget) CreatePortal(name string) error
func (*ISCSITarget) CreateTarget ¶
func (tgt *ISCSITarget) CreateTarget(target *api.SCSITarget) error
func (*ISCSITarget) DestroyPortal ¶
func (tgt *ISCSITarget) DestroyPortal(name string) error
func (*ISCSITarget) DestroyTarget ¶
func (tgt *ISCSITarget) DestroyTarget(target *api.SCSITarget) error
func (*ISCSITarget) Exit ¶
func (tgt *ISCSITarget) Exit() error
func (*ISCSITarget) Init ¶
func (tgt *ISCSITarget) Init() error
type ISCSITargetDriver ¶
type ISCSITargetDriver struct { SCSI *scsi.SCSITargetService Name string TSIHPool map[uint16]bool TSIHPoolMutex sync.Mutex // contains filtered or unexported fields }
func (*ISCSITargetDriver) AddiSCSIPortal ¶
func (s *ISCSITargetDriver) AddiSCSIPortal(tgtName string, tpgt uint16, portal string) error
func (*ISCSITargetDriver) AllocTSIH ¶
func (s *ISCSITargetDriver) AllocTSIH() uint16
func (*ISCSITargetDriver) BindISCSISession ¶
func (s *ISCSITargetDriver) BindISCSISession(conn *iscsiConnection) error
func (*ISCSITargetDriver) HasPortal ¶
func (s *ISCSITargetDriver) HasPortal(tgtName string, tpgt uint16, portal string) bool
func (*ISCSITargetDriver) LookupISCSISession ¶
func (s *ISCSITargetDriver) LookupISCSISession(tgtName string, iniName string, isid uint64, tsih uint16, tpgt uint16) *ISCSISession
func (*ISCSITargetDriver) NewISCSISession ¶
func (s *ISCSITargetDriver) NewISCSISession(conn *iscsiConnection) (*ISCSISession, error)
New creates a new session.
func (*ISCSITargetDriver) NewTarget ¶
func (s *ISCSITargetDriver) NewTarget(tgtName string, configInfo *config.Config) error
func (*ISCSITargetDriver) ReInstatement ¶
func (s *ISCSITargetDriver) ReInstatement(existSess *ISCSISession, conn *iscsiConnection) (*ISCSISession, error)
func (*ISCSITargetDriver) ReleaseTSIH ¶
func (s *ISCSITargetDriver) ReleaseTSIH(tsih uint16)
func (*ISCSITargetDriver) Run ¶
func (s *ISCSITargetDriver) Run() error
func (*ISCSITargetDriver) UnBindISCSISession ¶
func (s *ISCSITargetDriver) UnBindISCSISession(sess *ISCSISession)
type KeyConvFunc ¶
* The defaults here are according to the spec and must not be changed, * otherwise the initiator may make the wrong assumption. If you want * to change a value, edit the value in iscsi_target_create. * * The param MaxXmitDataSegmentLength doesn't really exist. It's a way * to remember the RDSL of the initiator, which defaults to 8k if he has * not told us otherwise.