Commit 7996a778 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] iscsi: add libiscsi

There is a lot of code duplcited between iscsi_tcp
and the upcoming iscsi_iser driver. This patch puts
the duplicated code in a lib. There is more code
to move around but this takes care of the
basics. For iscsi_offload if they use the lib we will
probably move some things around. For example in the
queuecommand we will not assume that the LLD wants
to do queue_work, but it is better to handle that
later when we know for sure what iscsi_offload looks
like (we could probably do this for iscsi_iser though to).

Ideally I would like to get the iscsi_transports modules
to a place where all they really have to do is put data
on the wire, but how to do that will hopefully be more clear
when we see other modules like iscsi_offload. Or maybe
iscsi_offload will not use the lib and it will just be
iscsi_iser and iscsi_tcp and maybe the iscsi_tcp_tgt if that
is allowed in mainline.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 30a6c652
...@@ -33,7 +33,7 @@ obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o ...@@ -33,7 +33,7 @@ obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o
obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o
obj-$(CONFIG_ISCSI_TCP) += iscsi_tcp.o obj-$(CONFIG_ISCSI_TCP) += libiscsi.o iscsi_tcp.o
obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o
obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o
......
This diff is collapsed.
...@@ -471,106 +471,6 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn) ...@@ -471,106 +471,6 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
EXPORT_SYMBOL_GPL(iscsi_destroy_conn); EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
/*
* These functions are used only by software iscsi_transports
* which do not allocate and more their scsi_hosts since this
* is initiated from userspace.
*/
/*
* iSCSI Session's hostdata organization:
*
* *------------------* <== hostdata_session(host->hostdata)
* | ptr to class sess|
* |------------------| <== iscsi_hostdata(host->hostdata)
* | transport's data |
* *------------------*
*/
#define hostdata_privsize(_t) (sizeof(unsigned long) + _t->hostdata_size + \
_t->hostdata_size % sizeof(unsigned long))
#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
/**
* iscsi_transport_create_session - create iscsi cls session and host
* scsit: scsi transport template
* transport: iscsi transport template
*
* This can be used by software iscsi_transports that allocate
* a session per scsi host.
**/
struct Scsi_Host *
iscsi_transport_create_session(struct scsi_transport_template *scsit,
struct iscsi_transport *transport)
{
struct iscsi_cls_session *session;
struct Scsi_Host *shost;
unsigned long flags;
shost = scsi_host_alloc(transport->host_template,
hostdata_privsize(transport));
if (!shost) {
printk(KERN_ERR "iscsi: can not allocate SCSI host for "
"session\n");
return NULL;
}
shost->max_id = 1;
shost->max_channel = 0;
shost->max_lun = transport->max_lun;
shost->max_cmd_len = transport->max_cmd_len;
shost->transportt = scsit;
shost->transportt->create_work_queue = 1;
if (scsi_add_host(shost, NULL))
goto free_host;
session = iscsi_create_session(shost, transport, 0);
if (!session)
goto remove_host;
*(unsigned long*)shost->hostdata = (unsigned long)session;
spin_lock_irqsave(&sesslock, flags);
list_add(&session->sess_list, &sesslist);
spin_unlock_irqrestore(&sesslock, flags);
return shost;
remove_host:
scsi_remove_host(shost);
free_host:
scsi_host_put(shost);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_transport_create_session);
/**
* iscsi_transport_destroy_session - destroy session and scsi host
* shost: scsi host
*
* This can be used by software iscsi_transports that allocate
* a session per scsi host.
**/
int iscsi_transport_destroy_session(struct Scsi_Host *shost)
{
struct iscsi_cls_session *session;
unsigned long flags;
session = hostdata_session(shost->hostdata);
spin_lock_irqsave(&sesslock, flags);
list_del(&session->sess_list);
spin_unlock_irqrestore(&sesslock, flags);
iscsi_destroy_session(session);
scsi_remove_host(shost);
/* ref from host alloc */
scsi_host_put(shost);
return 0;
}
EXPORT_SYMBOL_GPL(iscsi_transport_destroy_session);
/* /*
* iscsi interface functions * iscsi interface functions
*/ */
...@@ -857,14 +757,19 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev) ...@@ -857,14 +757,19 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
{ {
struct iscsi_transport *transport = priv->iscsi_transport; struct iscsi_transport *transport = priv->iscsi_transport;
struct iscsi_cls_session *session; struct iscsi_cls_session *session;
unsigned long flags;
uint32_t hostno; uint32_t hostno;
session = transport->create_session(&priv->t, session = transport->create_session(transport, &priv->t,
ev->u.c_session.initial_cmdsn, ev->u.c_session.initial_cmdsn,
&hostno); &hostno);
if (!session) if (!session)
return -ENOMEM; return -ENOMEM;
spin_lock_irqsave(&sesslock, flags);
list_add(&session->sess_list, &sesslist);
spin_unlock_irqrestore(&sesslock, flags);
ev->r.c_session_ret.host_no = hostno; ev->r.c_session_ret.host_no = hostno;
ev->r.c_session_ret.sid = session->sid; ev->r.c_session_ret.sid = session->sid;
return 0; return 0;
...@@ -1032,6 +937,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1032,6 +937,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
struct iscsi_internal *priv; struct iscsi_internal *priv;
struct iscsi_cls_session *session; struct iscsi_cls_session *session;
struct iscsi_cls_conn *conn; struct iscsi_cls_conn *conn;
unsigned long flags;
priv = iscsi_if_transport_lookup(iscsi_ptr(ev->transport_handle)); priv = iscsi_if_transport_lookup(iscsi_ptr(ev->transport_handle));
if (!priv) if (!priv)
...@@ -1047,9 +953,13 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1047,9 +953,13 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
break; break;
case ISCSI_UEVENT_DESTROY_SESSION: case ISCSI_UEVENT_DESTROY_SESSION:
session = iscsi_session_lookup(ev->u.d_session.sid); session = iscsi_session_lookup(ev->u.d_session.sid);
if (session) if (session) {
spin_lock_irqsave(&sesslock, flags);
list_del(&session->sess_list);
spin_unlock_irqrestore(&sesslock, flags);
transport->destroy_session(session); transport->destroy_session(session);
else } else
err = -EINVAL; err = -EINVAL;
break; break;
case ISCSI_UEVENT_CREATE_CONN: case ISCSI_UEVENT_CREATE_CONN:
......
...@@ -148,7 +148,8 @@ enum iscsi_err { ...@@ -148,7 +148,8 @@ enum iscsi_err {
ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13, ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14, ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
}; };
/* /*
......
/*
* iSCSI lib definitions
*
* Copyright (C) 2006 Red Hat, Inc. All rights reserved.
* Copyright (C) 2004 - 2006 Mike Christie
* Copyright (C) 2004 - 2005 Dmitry Yusupov
* Copyright (C) 2004 - 2005 Alex Aizman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef LIBISCSI_H
#define LIBISCSI_H
#include <linux/types.h>
#include <linux/mutex.h>
#include <scsi/iscsi_proto.h>
#include <scsi/iscsi_if.h>
struct scsi_transport_template;
struct scsi_device;
struct Scsi_Host;
struct scsi_cmnd;
struct socket;
struct iscsi_transport;
struct iscsi_cls_session;
struct iscsi_cls_conn;
struct iscsi_session;
struct iscsi_nopin;
/* #define DEBUG_SCSI */
#ifdef DEBUG_SCSI
#define debug_scsi(fmt...) printk(KERN_INFO "scsi: " fmt)
#else
#define debug_scsi(fmt...)
#endif
#define ISCSI_XMIT_CMDS_MAX 128 /* must be power of 2 */
#define ISCSI_MGMT_CMDS_MAX 32 /* must be power of 2 */
#define ISCSI_CONN_MAX 1
#define ISCSI_MGMT_ITT_OFFSET 0xa00
#define ISCSI_DEF_CMD_PER_LUN 32
#define ISCSI_MAX_CMD_PER_LUN 128
/* Task Mgmt states */
#define TMABORT_INITIAL 0x0
#define TMABORT_SUCCESS 0x1
#define TMABORT_FAILED 0x2
#define TMABORT_TIMEDOUT 0x3
/* Connection suspend "bit" */
#define ISCSI_SUSPEND_BIT 1
#define ISCSI_ITT_MASK (0xfff)
#define ISCSI_CID_SHIFT 12
#define ISCSI_CID_MASK (0xffff << ISCSI_CID_SHIFT)
#define ISCSI_AGE_SHIFT 28
#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT)
struct iscsi_mgmt_task {
/*
* Becuae LLDs allocate their hdr differently, this is a pointer to
* that storage. It must be setup at session creation time.
*/
struct iscsi_hdr *hdr;
char *data; /* mgmt payload */
int data_count; /* counts data to be sent */
uint32_t itt; /* this ITT */
void *dd_data; /* driver/transport data */
struct list_head running;
};
struct iscsi_cmd_task {
/*
* Becuae LLDs allocate their hdr differently, this is a pointer to
* that storage. It must be setup at session creation time.
*/
struct iscsi_cmd *hdr;
int itt; /* this ITT */
int datasn; /* DataSN */
uint32_t unsol_datasn;
int imm_count; /* imm-data (bytes) */
int unsol_count; /* unsolicited (bytes)*/
int data_count; /* remaining Data-Out */
struct scsi_cmnd *sc; /* associated SCSI cmd*/
int total_length;
struct iscsi_conn *conn; /* used connection */
struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */
struct list_head running; /* running cmd list */
void *dd_data; /* driver/transport data */
};
struct iscsi_conn {
struct iscsi_cls_conn *cls_conn; /* ptr to class connection */
void *dd_data; /* iscsi_transport data */
struct iscsi_session *session; /* parent session */
/*
* LLDs should set this lock. It protects the transport recv
* code
*/
rwlock_t *recv_lock;
/*
* conn_stop() flag: stop to recover, stop to terminate
*/
int stop_stage;
/* iSCSI connection-wide sequencing */
uint32_t exp_statsn;
/* control data */
int id; /* CID */
struct list_head item; /* maintains list of conns */
int c_stage; /* connection state */
struct iscsi_mgmt_task *login_mtask; /* mtask used for login/text */
struct iscsi_mgmt_task *mtask; /* xmit mtask in progress */
struct iscsi_cmd_task *ctask; /* xmit ctask in progress */
/* xmit */
struct kfifo *immqueue; /* immediate xmit queue */
struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */
struct list_head mgmt_run_list; /* list of control tasks */
struct kfifo *xmitqueue; /* data-path cmd queue */
struct list_head run_list; /* list of cmds in progress */
struct work_struct xmitwork; /* per-conn. xmit workqueue */
/*
* serializes connection xmit, access to kfifos:
* xmitqueue, immqueue, mgmtqueue
*/
struct mutex xmitmutex;
unsigned long suspend_tx; /* suspend Tx */
unsigned long suspend_rx; /* suspend Rx */
/* abort */
wait_queue_head_t ehwait; /* used in eh_abort() */
struct iscsi_tm tmhdr;
struct timer_list tmabort_timer;
int tmabort_state; /* see TMABORT_INITIAL, etc.*/
/* negotiated params */
int max_recv_dlength; /* initiator_max_recv_dsl*/
int max_xmit_dlength; /* target_max_recv_dsl */
int hdrdgst_en;
int datadgst_en;
/* MIB-statistics */
uint64_t txdata_octets;
uint64_t rxdata_octets;
uint32_t scsicmd_pdus_cnt;
uint32_t dataout_pdus_cnt;
uint32_t scsirsp_pdus_cnt;
uint32_t datain_pdus_cnt;
uint32_t r2t_pdus_cnt;
uint32_t tmfcmd_pdus_cnt;
int32_t tmfrsp_pdus_cnt;
/* custom statistics */
uint32_t eh_abort_cnt;
};
struct iscsi_queue {
struct kfifo *queue; /* FIFO Queue */
void **pool; /* Pool of elements */
int max; /* Max number of elements */
};
struct iscsi_session {
/* iSCSI session-wide sequencing */
uint32_t cmdsn;
uint32_t exp_cmdsn;
uint32_t max_cmdsn;
/* configuration */
int initial_r2t_en;
int max_r2t;
int imm_data_en;
int first_burst;
int max_burst;
int time2wait;
int time2retain;
int pdu_inorder_en;
int dataseq_inorder_en;
int erl;
int ifmarker_en;
int ofmarker_en;
/* control data */
struct iscsi_transport *tt;
struct Scsi_Host *host;
struct iscsi_conn *leadconn; /* leading connection */
spinlock_t lock; /* protects session state, *
* sequence numbers, *
* session resources: *
* - cmdpool, *
* - mgmtpool, *
* - r2tpool */
int state; /* session state */
int recovery_failed;
struct list_head item;
int conn_cnt;
int age; /* counts session re-opens */
struct list_head connections; /* list of connections */
int cmds_max; /* size of cmds array */
struct iscsi_cmd_task **cmds; /* Original Cmds arr */
struct iscsi_queue cmdpool; /* PDU's pool */
int mgmtpool_max; /* size of mgmt array */
struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */
struct iscsi_queue mgmtpool; /* Mgmt PDU's pool */
};
/*
* scsi host template
*/
extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
extern int iscsi_eh_abort(struct scsi_cmnd *sc);
extern int iscsi_eh_host_reset(struct scsi_cmnd *sc);
extern int iscsi_queuecommand(struct scsi_cmnd *sc,
void (*done)(struct scsi_cmnd *));
/*
* session management
*/
extern struct iscsi_cls_session *
iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *,
int, int, uint32_t, uint32_t *);
extern void iscsi_session_teardown(struct iscsi_cls_session *);
extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *);
extern void iscsi_start_session_recovery(struct iscsi_session *,
struct iscsi_conn *, int);
extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
#define session_to_cls(_sess) \
hostdata_session(_sess->host->hostdata)
/*
* connection management
*/
extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *,
uint32_t);
extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
extern int iscsi_conn_start(struct iscsi_cls_conn *);
extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
int);
extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
/*
* pdu and task processing
*/
extern int iscsi_check_assign_cmdsn(struct iscsi_session *,
struct iscsi_nopin *);
extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *,
struct iscsi_data *hdr,
int transport_data_cnt);
extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
char *, uint32_t);
extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
char *, int);
extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
char *, int);
extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *,
uint32_t *);
/*
* generic helpers
*/
extern void iscsi_pool_free(struct iscsi_queue *, void **);
extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int);
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* iSCSI transport class definitions * iSCSI transport class definitions
* *
* Copyright (C) IBM Corporation, 2004 * Copyright (C) IBM Corporation, 2004
* Copyright (C) Mike Christie, 2004 - 2005 * Copyright (C) Mike Christie, 2004 - 2006
* Copyright (C) Dmitry Yusupov, 2004 - 2005 * Copyright (C) Dmitry Yusupov, 2004 - 2005
* Copyright (C) Alex Aizman, 2004 - 2005 * Copyright (C) Alex Aizman, 2004 - 2005
* *
...@@ -27,9 +27,13 @@ ...@@ -27,9 +27,13 @@
#include <scsi/iscsi_if.h> #include <scsi/iscsi_if.h>
struct scsi_transport_template; struct scsi_transport_template;
struct iscsi_transport;
struct Scsi_Host; struct Scsi_Host;
struct mempool_zone; struct mempool_zone;
struct iscsi_cls_conn; struct iscsi_cls_conn;
struct iscsi_conn;
struct iscsi_cmd_task;
struct iscsi_mgmt_task;
/** /**
* struct iscsi_transport - iSCSI Transport template * struct iscsi_transport - iSCSI Transport template
...@@ -46,6 +50,20 @@ struct iscsi_cls_conn; ...@@ -46,6 +50,20 @@ struct iscsi_cls_conn;
* @start_conn: set connection to be operational * @start_conn: set connection to be operational
* @stop_conn: suspend/recover/terminate connection * @stop_conn: suspend/recover/terminate connection
* @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text.
* @session_recovery_timedout: notify LLD a block during recovery timed out
* @suspend_conn_recv: susepend the recv side of the connection
* @termincate_conn: destroy socket connection. Called with mutex lock.
* @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs.
* Called from queuecommand with session lock held.
* @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs.
* Called from iscsi_conn_send_generic with xmitmutex.
* @xmit_cmd_task: requests LLD to transfer cmd task
* @xmit_mgmt_task: requests LLD to transfer mgmt task
* @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex
* and session->lock after the connection has been
* suspended and terminated during recovery. If called
* from abort task then connection is not suspended
* or terminated but sk_callback_lock is held
* *
* Template API provided by iSCSI Transport * Template API provided by iSCSI Transport
*/ */
...@@ -56,8 +74,6 @@ struct iscsi_transport { ...@@ -56,8 +74,6 @@ struct iscsi_transport {
/* LLD sets this to indicate what values it can export to sysfs */ /* LLD sets this to indicate what values it can export to sysfs */
unsigned int param_mask; unsigned int param_mask;
struct scsi_host_template *host_template; struct scsi_host_template *host_template;
/* LLD session/scsi_host data size */
int hostdata_size;
/* LLD connection data size */ /* LLD connection data size */
int conndata_size; int conndata_size;
/* LLD session data size */ /* LLD session data size */
...@@ -65,8 +81,8 @@ struct iscsi_transport { ...@@ -65,8 +81,8 @@ struct iscsi_transport {
int max_lun; int max_lun;
unsigned int max_conn; unsigned int max_conn;
unsigned int max_cmd_len; unsigned int max_cmd_len;
struct iscsi_cls_session *(*create_session) struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it,
(struct scsi_transport_template *t, uint32_t sn, uint32_t *hn); struct scsi_transport_template *t, uint32_t sn, uint32_t *hn);
void (*destroy_session) (struct iscsi_cls_session *session); void (*destroy_session) (struct iscsi_cls_session *session);
struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
uint32_t cid); uint32_t cid);
...@@ -90,6 +106,18 @@ struct iscsi_transport { ...@@ -90,6 +106,18 @@ struct iscsi_transport {
char *data, uint32_t data_size); char *data, uint32_t data_size);
void (*get_stats) (struct iscsi_cls_conn *conn, void (*get_stats) (struct iscsi_cls_conn *conn,
struct iscsi_stats *stats); struct iscsi_stats *stats);
void (*suspend_conn_recv) (struct iscsi_conn *conn);
void (*terminate_conn) (struct iscsi_conn *conn);
void (*init_cmd_task) (struct iscsi_cmd_task *ctask);
void (*init_mgmt_task) (struct iscsi_conn *conn,
struct iscsi_mgmt_task *mtask,
char *data, uint32_t data_size);
int (*xmit_cmd_task) (struct iscsi_conn *conn,
struct iscsi_cmd_task *ctask);
void (*cleanup_cmd_task) (struct iscsi_conn *conn,
struct iscsi_cmd_task *ctask);
int (*xmit_mgmt_task) (struct iscsi_conn *conn,
struct iscsi_mgmt_task *mtask);
void (*session_recovery_timedout) (struct iscsi_cls_session *session); void (*session_recovery_timedout) (struct iscsi_cls_session *session);
}; };
...@@ -106,6 +134,13 @@ extern void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error); ...@@ -106,6 +134,13 @@ extern void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error);
extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size); char *data, uint32_t data_size);
/* Connection's states */
#define ISCSI_CONN_INITIAL_STAGE 0
#define ISCSI_CONN_STARTED 1
#define ISCSI_CONN_STOPPED 2
#define ISCSI_CONN_CLEANUP_WAIT 3
struct iscsi_cls_conn { struct iscsi_cls_conn {
struct list_head conn_list; /* item in connlist */ struct list_head conn_list; /* item in connlist */
void *dd_data; /* LLD private data */ void *dd_data; /* LLD private data */
...@@ -129,6 +164,12 @@ struct iscsi_cls_conn { ...@@ -129,6 +164,12 @@ struct iscsi_cls_conn {
#define iscsi_dev_to_conn(_dev) \ #define iscsi_dev_to_conn(_dev) \
container_of(_dev, struct iscsi_cls_conn, dev) container_of(_dev, struct iscsi_cls_conn, dev)
/* Session's states */
#define ISCSI_STATE_FREE 1
#define ISCSI_STATE_LOGGED_IN 2
#define ISCSI_STATE_FAILED 3
#define ISCSI_STATE_TERMINATE 4
struct iscsi_cls_session { struct iscsi_cls_session {
struct list_head sess_list; /* item in session_list */ struct list_head sess_list; /* item in session_list */
struct list_head host_list; struct list_head host_list;
...@@ -174,12 +215,4 @@ extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); ...@@ -174,12 +215,4 @@ extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
extern void iscsi_unblock_session(struct iscsi_cls_session *session); extern void iscsi_unblock_session(struct iscsi_cls_session *session);
extern void iscsi_block_session(struct iscsi_cls_session *session); extern void iscsi_block_session(struct iscsi_cls_session *session);
/*
* session functions used by software iscsi
*/
extern struct Scsi_Host *
iscsi_transport_create_session(struct scsi_transport_template *scsit,
struct iscsi_transport *transport);
extern int iscsi_transport_destroy_session(struct Scsi_Host *shost);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment