summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-06-21 11:18:25 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-21 11:18:25 -0700
commit28e4b224955cbe30275b2a7842e729023a4f4b03 (patch)
treeab4d28fecc06070fc2a2742f4b4550b29de44912 /include
parent22ae813b85df7c0b0fc7c8d6f336d6a9f566ff97 (diff)
parent67d59dfdeb21df2c16dcd478b66177e91178ecd0 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (85 commits) [SCSI] 53c700: remove reliance on deprecated cmnd fields [SCSI] hptiop: don't use cmnd->bufflen [SCSI] hptiop: HighPoint RocketRAID 3xxx controller driver [SCSI] aacraid: small misc. cleanups [SCSI] aacraid: Update supported product information [SCSI] aacraid: Fix return code interpretation [SCSI] scsi_transport_sas: fix panic in sas_free_rphy [SCSI] remove RQ_SCSI_* flags [SCSI] remove scsi_request infrastructure [SCSI] mptfusion: change driver revision to 3.03.10 [SCSI] mptfc: abort of board reset leaves port dead requiring reboot [SCSI] mptfc: fix fibre channel infinite request/response loop [SCSI] mptfc: set fibre channel fw target missing timers to one second [SCSI] mptfusion: move fc event/reset handling to mptfc [SCSI] spi transport: don't allow dt to be set on SE or HVD buses [SCSI] aic7xxx: expose the bus setting to sysfs [SCSI] scsi: remove Documentation/scsi/cpqfc.txt [SCSI] drivers/scsi: Use ARRAY_SIZE macro [SCSI] Remove last page_address from dc395x.c [SCSI] hptiop: HighPoint RocketRAID 3xxx controller driver ... Fixed up conflicts in drivers/message/fusion/mptbase.c manually (due to the sparc interrupt cleanups)
Diffstat (limited to 'include')
-rw-r--r--include/linux/blkdev.h3
-rw-r--r--include/scsi/iscsi_if.h127
-rw-r--r--include/scsi/iscsi_proto.h2
-rw-r--r--include/scsi/libiscsi.h282
-rw-r--r--include/scsi/scsi_cmnd.h10
-rw-r--r--include/scsi/scsi_dbg.h2
-rw-r--r--include/scsi/scsi_devinfo.h1
-rw-r--r--include/scsi/scsi_eh.h3
-rw-r--r--include/scsi/scsi_request.h54
-rw-r--r--include/scsi/scsi_transport_iscsi.h119
-rw-r--r--include/scsi/sg_request.h26
11 files changed, 482 insertions, 147 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 5d327313a9f7..3457e7b97363 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -438,9 +438,6 @@ struct request_queue
#define RQ_INACTIVE (-1)
#define RQ_ACTIVE 1
-#define RQ_SCSI_BUSY 0xffff
-#define RQ_SCSI_DONE 0xfffe
-#define RQ_SCSI_DISCONNECTING 0xffe0
#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index e5618b90996e..253797c60095 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -43,6 +43,10 @@ enum iscsi_uevent_e {
ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
+ ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
+ ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
+ ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
+
/* up events */
ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
@@ -60,61 +64,83 @@ struct iscsi_uevent {
uint32_t initial_cmdsn;
} c_session;
struct msg_destroy_session {
- uint64_t session_handle;
uint32_t sid;
} d_session;
struct msg_create_conn {
- uint64_t session_handle;
- uint32_t cid;
uint32_t sid;
+ uint32_t cid;
} c_conn;
struct msg_bind_conn {
- uint64_t session_handle;
- uint64_t conn_handle;
- uint32_t transport_fd;
+ uint32_t sid;
+ uint32_t cid;
+ uint64_t transport_eph;
uint32_t is_leading;
} b_conn;
struct msg_destroy_conn {
- uint64_t conn_handle;
+ uint32_t sid;
uint32_t cid;
} d_conn;
struct msg_send_pdu {
+ uint32_t sid;
+ uint32_t cid;
uint32_t hdr_size;
uint32_t data_size;
- uint64_t conn_handle;
} send_pdu;
struct msg_set_param {
- uint64_t conn_handle;
+ uint32_t sid;
+ uint32_t cid;
uint32_t param; /* enum iscsi_param */
- uint32_t value;
+ uint32_t len;
} set_param;
struct msg_start_conn {
- uint64_t conn_handle;
+ uint32_t sid;
+ uint32_t cid;
} start_conn;
struct msg_stop_conn {
+ uint32_t sid;
+ uint32_t cid;
uint64_t conn_handle;
uint32_t flag;
} stop_conn;
struct msg_get_stats {
- uint64_t conn_handle;
+ uint32_t sid;
+ uint32_t cid;
} get_stats;
+ struct msg_transport_connect {
+ uint32_t non_blocking;
+ } ep_connect;
+ struct msg_transport_poll {
+ uint64_t ep_handle;
+ uint32_t timeout_ms;
+ } ep_poll;
+ struct msg_transport_disconnect {
+ uint64_t ep_handle;
+ } ep_disconnect;
} u;
union {
/* messages k -> u */
- uint64_t handle;
int retcode;
struct msg_create_session_ret {
- uint64_t session_handle;
uint32_t sid;
+ uint32_t host_no;
} c_session_ret;
+ struct msg_create_conn_ret {
+ uint32_t sid;
+ uint32_t cid;
+ } c_conn_ret;
struct msg_recv_req {
+ uint32_t sid;
+ uint32_t cid;
uint64_t recv_handle;
- uint64_t conn_handle;
} recv_req;
struct msg_conn_error {
- uint64_t conn_handle;
+ uint32_t sid;
+ uint32_t cid;
uint32_t error; /* enum iscsi_err */
} connerror;
+ struct msg_transport_connect_ret {
+ uint64_t handle;
+ } ep_connect_ret;
} r;
} __attribute__ ((aligned (sizeof(uint64_t))));
@@ -139,29 +165,66 @@ enum iscsi_err {
ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
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 Parameters (RFC3720)
*/
enum iscsi_param {
- ISCSI_PARAM_MAX_RECV_DLENGTH = 0,
- ISCSI_PARAM_MAX_XMIT_DLENGTH = 1,
- ISCSI_PARAM_HDRDGST_EN = 2,
- ISCSI_PARAM_DATADGST_EN = 3,
- ISCSI_PARAM_INITIAL_R2T_EN = 4,
- ISCSI_PARAM_MAX_R2T = 5,
- ISCSI_PARAM_IMM_DATA_EN = 6,
- ISCSI_PARAM_FIRST_BURST = 7,
- ISCSI_PARAM_MAX_BURST = 8,
- ISCSI_PARAM_PDU_INORDER_EN = 9,
- ISCSI_PARAM_DATASEQ_INORDER_EN = 10,
- ISCSI_PARAM_ERL = 11,
- ISCSI_PARAM_IFMARKER_EN = 12,
- ISCSI_PARAM_OFMARKER_EN = 13,
+ /* passed in using netlink set param */
+ ISCSI_PARAM_MAX_RECV_DLENGTH,
+ ISCSI_PARAM_MAX_XMIT_DLENGTH,
+ 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_EXP_STATSN,
+ ISCSI_PARAM_TARGET_NAME,
+ ISCSI_PARAM_TPGT,
+ ISCSI_PARAM_PERSISTENT_ADDRESS,
+ ISCSI_PARAM_PERSISTENT_PORT,
+ ISCSI_PARAM_SESS_RECOVERY_TMO,
+
+ /* pased in through bind conn using transport_fd */
+ ISCSI_PARAM_CONN_PORT,
+ ISCSI_PARAM_CONN_ADDRESS,
+
+ /* must always be last */
+ ISCSI_PARAM_MAX,
};
-#define ISCSI_PARAM_MAX 14
+
+#define ISCSI_MAX_RECV_DLENGTH (1 << ISCSI_PARAM_MAX_RECV_DLENGTH)
+#define ISCSI_MAX_XMIT_DLENGTH (1 << ISCSI_PARAM_MAX_XMIT_DLENGTH)
+#define ISCSI_HDRDGST_EN (1 << ISCSI_PARAM_HDRDGST_EN)
+#define ISCSI_DATADGST_EN (1 << ISCSI_PARAM_DATADGST_EN)
+#define ISCSI_INITIAL_R2T_EN (1 << ISCSI_PARAM_INITIAL_R2T_EN)
+#define ISCSI_MAX_R2T (1 << ISCSI_PARAM_MAX_R2T)
+#define ISCSI_IMM_DATA_EN (1 << ISCSI_PARAM_IMM_DATA_EN)
+#define ISCSI_FIRST_BURST (1 << ISCSI_PARAM_FIRST_BURST)
+#define ISCSI_MAX_BURST (1 << ISCSI_PARAM_MAX_BURST)
+#define ISCSI_PDU_INORDER_EN (1 << ISCSI_PARAM_PDU_INORDER_EN)
+#define ISCSI_DATASEQ_INORDER_EN (1 << ISCSI_PARAM_DATASEQ_INORDER_EN)
+#define ISCSI_ERL (1 << ISCSI_PARAM_ERL)
+#define ISCSI_IFMARKER_EN (1 << ISCSI_PARAM_IFMARKER_EN)
+#define ISCSI_OFMARKER_EN (1 << ISCSI_PARAM_OFMARKER_EN)
+#define ISCSI_EXP_STATSN (1 << ISCSI_PARAM_EXP_STATSN)
+#define ISCSI_TARGET_NAME (1 << ISCSI_PARAM_TARGET_NAME)
+#define ISCSI_TPGT (1 << ISCSI_PARAM_TPGT)
+#define ISCSI_PERSISTENT_ADDRESS (1 << ISCSI_PARAM_PERSISTENT_ADDRESS)
+#define ISCSI_PERSISTENT_PORT (1 << ISCSI_PARAM_PERSISTENT_PORT)
+#define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO)
+#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
+#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 4feda05fdf25..02f6e4b9e693 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -21,8 +21,6 @@
#ifndef ISCSI_PROTO_H
#define ISCSI_PROTO_H
-#define ISCSI_VERSION_STR "0.3"
-#define ISCSI_DATE_STR "22-Apr-2005"
#define ISCSI_DRAFT20_VERSION 0x00
/* default iSCSI listen port for incoming connections */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
new file mode 100644
index 000000000000..cbf7e58bd6f9
--- /dev/null
+++ b/include/scsi/libiscsi.h
@@ -0,0 +1,282 @@
+/*
+ * 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 "iscsi: " 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 */
+ struct list_head item;
+ 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_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
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 1ace1b9fe537..b0caabec1bd1 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -9,7 +9,6 @@
struct request;
struct scatterlist;
struct scsi_device;
-struct scsi_request;
/* embedded in scsi_cmnd */
@@ -29,13 +28,8 @@ struct scsi_pointer {
};
struct scsi_cmnd {
- int sc_magic;
-
struct scsi_device *device;
- struct scsi_request *sc_request;
-
struct list_head list; /* scsi_cmnd participates in queue lists */
-
struct list_head eh_entry; /* entry for the host eh_cmd_q */
int eh_eflags; /* Used by error handlr */
void (*done) (struct scsi_cmnd *); /* Mid-level done function */
@@ -152,4 +146,8 @@ extern void scsi_put_command(struct scsi_cmnd *);
extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
extern void scsi_finish_command(struct scsi_cmnd *cmd);
+extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
+ size_t *offset, size_t *len);
+extern void scsi_kunmap_atomic_sg(void *virt);
+
#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 4d69dee66d4d..3bbbfbe8cbfc 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -2,14 +2,12 @@
#define _SCSI_SCSI_DBG_H
struct scsi_cmnd;
-struct scsi_request;
struct scsi_sense_hdr;
extern void scsi_print_command(struct scsi_cmnd *);
extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *);
extern void __scsi_print_command(unsigned char *);
extern void scsi_print_sense(const char *, struct scsi_cmnd *);
-extern void scsi_print_req_sense(const char *, struct scsi_request *);
extern void __scsi_print_sense(const char *name,
const unsigned char *sense_buffer,
int sense_len);
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index d31b16d25a09..b4ddd3b18b4c 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -29,4 +29,5 @@
#define BLIST_SELECT_NO_ATN 0x200000 /* select without ATN */
#define BLIST_RETRY_HWERROR 0x400000 /* retry HARDWARE_ERROR */
#define BLIST_MAX_512 0x800000 /* maximum 512 sector cdb length */
+#define BLIST_ATTACH_PQ3 0x1000000 /* Scan: Attach to PQ3 devices */
#endif
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index d160880b2a87..c5c0f6762a01 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -3,7 +3,6 @@
struct scsi_cmnd;
struct scsi_device;
-struct scsi_request;
struct Scsi_Host;
/*
@@ -43,8 +42,6 @@ extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
extern int scsi_block_when_processing_errors(struct scsi_device *);
extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
struct scsi_sense_hdr *sshdr);
-extern int scsi_request_normalize_sense(struct scsi_request *sreq,
- struct scsi_sense_hdr *sshdr);
extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
struct scsi_sense_hdr *sshdr);
diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
deleted file mode 100644
index 98d69fdb851c..000000000000
--- a/include/scsi/scsi_request.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef _SCSI_SCSI_REQUEST_H
-#define _SCSI_SCSI_REQUEST_H
-
-#include <scsi/scsi_cmnd.h>
-
-struct request;
-struct scsi_cmnd;
-struct scsi_device;
-struct Scsi_Host;
-
-
-/*
- * This is essentially a slimmed down version of Scsi_Cmnd. The point of
- * having this is that requests that are injected into the queue as result
- * of things like ioctls and character devices shouldn't be using a
- * Scsi_Cmnd until such a time that the command is actually at the head
- * of the queue and being sent to the driver.
- */
-struct scsi_request {
- int sr_magic;
- int sr_result; /* Status code from lower level driver */
- unsigned char sr_sense_buffer[SCSI_SENSE_BUFFERSIZE]; /* obtained by REQUEST SENSE
- * when CHECK CONDITION is
- * received on original command
- * (auto-sense) */
-
- struct Scsi_Host *sr_host;
- struct scsi_device *sr_device;
- struct scsi_cmnd *sr_command;
- struct request *sr_request; /* A copy of the command we are
- working on */
- unsigned sr_bufflen; /* Size of data buffer */
- void *sr_buffer; /* Data buffer */
- int sr_allowed;
- enum dma_data_direction sr_data_direction;
- unsigned char sr_cmd_len;
- unsigned char sr_cmnd[MAX_COMMAND_SIZE];
- void (*sr_done) (struct scsi_cmnd *); /* Mid-level done function */
- int sr_timeout_per_command;
- unsigned short sr_use_sg; /* Number of pieces of scatter-gather */
- unsigned short sr_sglist_len; /* size of malloc'd scatter-gather list */
- unsigned sr_underflow; /* Return error if less than
- this amount is transferred */
- void *upper_private_data; /* reserved for owner (usually upper
- level driver) of this request */
-};
-
-extern struct scsi_request *scsi_allocate_request(struct scsi_device *, gfp_t);
-extern void scsi_release_request(struct scsi_request *);
-extern void scsi_do_req(struct scsi_request *, const void *cmnd,
- void *buffer, unsigned bufflen,
- void (*done) (struct scsi_cmnd *),
- int timeout, int retries);
-#endif /* _SCSI_SCSI_REQUEST_H */
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index b41cf077e54b..b684426a5900 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -2,7 +2,7 @@
* iSCSI transport class definitions
*
* 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) Alex Aizman, 2004 - 2005
*
@@ -27,9 +27,13 @@
#include <scsi/iscsi_if.h>
struct scsi_transport_template;
+struct iscsi_transport;
struct Scsi_Host;
struct mempool_zone;
struct iscsi_cls_conn;
+struct iscsi_conn;
+struct iscsi_cmd_task;
+struct iscsi_mgmt_task;
/**
* struct iscsi_transport - iSCSI Transport template
@@ -46,6 +50,24 @@ struct iscsi_cls_conn;
* @start_conn: set connection to be operational
* @stop_conn: suspend/recover/terminate connection
* @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. Returns 0 or the
+ * the number of bytes transferred on success, and -Exyz
+ * value on error.
+ * @xmit_mgmt_task: Requests LLD to transfer mgmt task. Returns 0 or the
+ * the number of bytes transferred on success, and -Exyz
+ * value on error.
+ * @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
*/
@@ -53,38 +75,58 @@ struct iscsi_transport {
struct module *owner;
char *name;
unsigned int caps;
+ /* LLD sets this to indicate what values it can export to sysfs */
+ unsigned int param_mask;
struct scsi_host_template *host_template;
- /* LLD session/scsi_host data size */
- int hostdata_size;
- /* LLD iscsi_host data size */
- int ihostdata_size;
/* LLD connection data size */
int conndata_size;
+ /* LLD session data size */
+ int sessiondata_size;
int max_lun;
unsigned int max_conn;
unsigned int max_cmd_len;
- struct iscsi_cls_session *(*create_session)
- (struct scsi_transport_template *t, uint32_t sn, uint32_t *sid);
+ struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it,
+ struct scsi_transport_template *t, uint32_t sn, uint32_t *hn);
void (*destroy_session) (struct iscsi_cls_session *session);
struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
uint32_t cid);
int (*bind_conn) (struct iscsi_cls_session *session,
struct iscsi_cls_conn *cls_conn,
- uint32_t transport_fd, int is_leading);
+ uint64_t transport_eph, int is_leading);
int (*start_conn) (struct iscsi_cls_conn *conn);
void (*stop_conn) (struct iscsi_cls_conn *conn, int flag);
void (*destroy_conn) (struct iscsi_cls_conn *conn);
int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param,
uint32_t value);
int (*get_conn_param) (struct iscsi_cls_conn *conn,
- enum iscsi_param param,
- uint32_t *value);
+ enum iscsi_param param, uint32_t *value);
int (*get_session_param) (struct iscsi_cls_session *session,
enum iscsi_param param, uint32_t *value);
+ int (*get_conn_str_param) (struct iscsi_cls_conn *conn,
+ enum iscsi_param param, char *buf);
+ int (*get_session_str_param) (struct iscsi_cls_session *session,
+ enum iscsi_param param, char *buf);
int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size);
void (*get_stats) (struct iscsi_cls_conn *conn,
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);
+ int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking,
+ uint64_t *ep_handle);
+ int (*ep_poll) (uint64_t ep_handle, int timeout_ms);
+ void (*ep_disconnect) (uint64_t ep_handle);
};
/*
@@ -100,10 +142,26 @@ 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,
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 list_head conn_list; /* item in connlist */
void *dd_data; /* LLD private data */
struct iscsi_transport *transport;
+ uint32_t cid; /* connection id */
+
+ /* portal/group values we got during discovery */
+ char *persistent_address;
+ int persistent_port;
+ /* portal/group values we are currently using */
+ char *address;
+ int port;
+
int active; /* must be accessed with the connlock */
struct device dev; /* sysfs transport/container device */
struct mempool_zone *z_error;
@@ -114,9 +172,32 @@ struct iscsi_cls_conn {
#define iscsi_dev_to_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
+#define ISCSI_STATE_IN_RECOVERY 5
+#define ISCSI_STATE_RECOVERY_FAILED 6
+
struct iscsi_cls_session {
struct list_head sess_list; /* item in session_list */
+ struct list_head host_list;
struct iscsi_transport *transport;
+
+ /* iSCSI values used as unique id by userspace. */
+ char *targetname;
+ int tpgt;
+
+ /* recovery fields */
+ int recovery_tmo;
+ struct work_struct recovery_work;
+
+ int target_id;
+ int channel;
+
+ int sid; /* session id */
+ void *dd_data; /* LLD private data */
struct device dev; /* sysfs transport/container device */
};
@@ -126,22 +207,22 @@ struct iscsi_cls_session {
#define iscsi_session_to_shost(_session) \
dev_to_shost(_session->dev.parent)
+struct iscsi_host {
+ int next_target_id;
+ struct list_head sessions;
+ struct mutex mutex;
+};
+
/*
* session and connection functions that can be used by HW iSCSI LLDs
*/
extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost,
- struct iscsi_transport *t);
+ struct iscsi_transport *t, int channel);
extern int iscsi_destroy_session(struct iscsi_cls_session *session);
extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
uint32_t cid);
extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
-
-/*
- * 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);
+extern void iscsi_unblock_session(struct iscsi_cls_session *session);
+extern void iscsi_block_session(struct iscsi_cls_session *session);
#endif
diff --git a/include/scsi/sg_request.h b/include/scsi/sg_request.h
deleted file mode 100644
index 57ff525bdd3b..000000000000
--- a/include/scsi/sg_request.h
+++ /dev/null
@@ -1,26 +0,0 @@
-typedef struct scsi_request Scsi_Request;
-
-static Scsi_Request *dummy_cmdp; /* only used for sizeof */
-
-typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */
- unsigned short k_use_sg; /* Count of kernel scatter-gather pieces */
- unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */
- unsigned bufflen; /* Size of (aggregate) data buffer */
- unsigned b_malloc_len; /* actual len malloc'ed in buffer */
- void *buffer; /* Data buffer or scatter list (k_use_sg>0) */
- char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */
- unsigned char cmd_opcode; /* first byte of command */
-} Sg_scatter_hold;
-
-typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */
- Scsi_Request *my_cmdp; /* != 0 when request with lower levels */
- struct sg_request *nextrp; /* NULL -> tail request (slist) */
- struct sg_fd *parentfp; /* NULL -> not in use */
- Sg_scatter_hold data; /* hold buffer, perhaps scatter list */
- sg_io_hdr_t header; /* scsi command+info, see <scsi/sg.h> */
- unsigned char sense_b[sizeof (dummy_cmdp->sr_sense_buffer)];
- char res_used; /* 1 -> using reserve buffer, 0 -> not ... */
- char orphan; /* 1 -> drop on sight, 0 -> normal */
- char sg_io_owned; /* 1 -> packet belongs to SG_IO */
- volatile char done; /* 0->before bh, 1->before read, 2->read */
-} Sg_request;