diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2006-04-06 22:13:41 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-04-14 15:09:00 -0400 |
commit | 7996a778ff8c717cb1a7a294475c59cc8f1e9fb8 (patch) | |
tree | 3d7ee67ad547a65ad10f5c7e41e20f6124ee249b /include/scsi/scsi_transport_iscsi.h | |
parent | 30a6c65236f9d26e3325cae468f330b833a3878c (diff) |
[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: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/scsi/scsi_transport_iscsi.h')
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 9d2b99159ee7..b332d6e839fe 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * iSCSI transport class definitions | 2 | * iSCSI transport class definitions |
3 | * | 3 | * |
4 | * Copyright (C) IBM Corporation, 2004 | 4 | * Copyright (C) IBM Corporation, 2004 |
5 | * Copyright (C) Mike Christie, 2004 - 2005 | 5 | * Copyright (C) Mike Christie, 2004 - 2006 |
6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 | 6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 |
7 | * Copyright (C) Alex Aizman, 2004 - 2005 | 7 | * Copyright (C) Alex Aizman, 2004 - 2005 |
8 | * | 8 | * |
@@ -27,9 +27,13 @@ | |||
27 | #include <scsi/iscsi_if.h> | 27 | #include <scsi/iscsi_if.h> |
28 | 28 | ||
29 | struct scsi_transport_template; | 29 | struct scsi_transport_template; |
30 | struct iscsi_transport; | ||
30 | struct Scsi_Host; | 31 | struct Scsi_Host; |
31 | struct mempool_zone; | 32 | struct mempool_zone; |
32 | struct iscsi_cls_conn; | 33 | struct iscsi_cls_conn; |
34 | struct iscsi_conn; | ||
35 | struct iscsi_cmd_task; | ||
36 | struct iscsi_mgmt_task; | ||
33 | 37 | ||
34 | /** | 38 | /** |
35 | * struct iscsi_transport - iSCSI Transport template | 39 | * struct iscsi_transport - iSCSI Transport template |
@@ -46,6 +50,20 @@ struct iscsi_cls_conn; | |||
46 | * @start_conn: set connection to be operational | 50 | * @start_conn: set connection to be operational |
47 | * @stop_conn: suspend/recover/terminate connection | 51 | * @stop_conn: suspend/recover/terminate connection |
48 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. | 52 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. |
53 | * @session_recovery_timedout: notify LLD a block during recovery timed out | ||
54 | * @suspend_conn_recv: susepend the recv side of the connection | ||
55 | * @termincate_conn: destroy socket connection. Called with mutex lock. | ||
56 | * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs. | ||
57 | * Called from queuecommand with session lock held. | ||
58 | * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs. | ||
59 | * Called from iscsi_conn_send_generic with xmitmutex. | ||
60 | * @xmit_cmd_task: requests LLD to transfer cmd task | ||
61 | * @xmit_mgmt_task: requests LLD to transfer mgmt task | ||
62 | * @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex | ||
63 | * and session->lock after the connection has been | ||
64 | * suspended and terminated during recovery. If called | ||
65 | * from abort task then connection is not suspended | ||
66 | * or terminated but sk_callback_lock is held | ||
49 | * | 67 | * |
50 | * Template API provided by iSCSI Transport | 68 | * Template API provided by iSCSI Transport |
51 | */ | 69 | */ |
@@ -56,8 +74,6 @@ struct iscsi_transport { | |||
56 | /* LLD sets this to indicate what values it can export to sysfs */ | 74 | /* LLD sets this to indicate what values it can export to sysfs */ |
57 | unsigned int param_mask; | 75 | unsigned int param_mask; |
58 | struct scsi_host_template *host_template; | 76 | struct scsi_host_template *host_template; |
59 | /* LLD session/scsi_host data size */ | ||
60 | int hostdata_size; | ||
61 | /* LLD connection data size */ | 77 | /* LLD connection data size */ |
62 | int conndata_size; | 78 | int conndata_size; |
63 | /* LLD session data size */ | 79 | /* LLD session data size */ |
@@ -65,8 +81,8 @@ struct iscsi_transport { | |||
65 | int max_lun; | 81 | int max_lun; |
66 | unsigned int max_conn; | 82 | unsigned int max_conn; |
67 | unsigned int max_cmd_len; | 83 | unsigned int max_cmd_len; |
68 | struct iscsi_cls_session *(*create_session) | 84 | struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, |
69 | (struct scsi_transport_template *t, uint32_t sn, uint32_t *hn); | 85 | struct scsi_transport_template *t, uint32_t sn, uint32_t *hn); |
70 | void (*destroy_session) (struct iscsi_cls_session *session); | 86 | void (*destroy_session) (struct iscsi_cls_session *session); |
71 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, | 87 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, |
72 | uint32_t cid); | 88 | uint32_t cid); |
@@ -90,6 +106,18 @@ struct iscsi_transport { | |||
90 | char *data, uint32_t data_size); | 106 | char *data, uint32_t data_size); |
91 | void (*get_stats) (struct iscsi_cls_conn *conn, | 107 | void (*get_stats) (struct iscsi_cls_conn *conn, |
92 | struct iscsi_stats *stats); | 108 | struct iscsi_stats *stats); |
109 | void (*suspend_conn_recv) (struct iscsi_conn *conn); | ||
110 | void (*terminate_conn) (struct iscsi_conn *conn); | ||
111 | void (*init_cmd_task) (struct iscsi_cmd_task *ctask); | ||
112 | void (*init_mgmt_task) (struct iscsi_conn *conn, | ||
113 | struct iscsi_mgmt_task *mtask, | ||
114 | char *data, uint32_t data_size); | ||
115 | int (*xmit_cmd_task) (struct iscsi_conn *conn, | ||
116 | struct iscsi_cmd_task *ctask); | ||
117 | void (*cleanup_cmd_task) (struct iscsi_conn *conn, | ||
118 | struct iscsi_cmd_task *ctask); | ||
119 | int (*xmit_mgmt_task) (struct iscsi_conn *conn, | ||
120 | struct iscsi_mgmt_task *mtask); | ||
93 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); | 121 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); |
94 | }; | 122 | }; |
95 | 123 | ||
@@ -106,6 +134,13 @@ extern void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error); | |||
106 | extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, | 134 | extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, |
107 | char *data, uint32_t data_size); | 135 | char *data, uint32_t data_size); |
108 | 136 | ||
137 | |||
138 | /* Connection's states */ | ||
139 | #define ISCSI_CONN_INITIAL_STAGE 0 | ||
140 | #define ISCSI_CONN_STARTED 1 | ||
141 | #define ISCSI_CONN_STOPPED 2 | ||
142 | #define ISCSI_CONN_CLEANUP_WAIT 3 | ||
143 | |||
109 | struct iscsi_cls_conn { | 144 | struct iscsi_cls_conn { |
110 | struct list_head conn_list; /* item in connlist */ | 145 | struct list_head conn_list; /* item in connlist */ |
111 | void *dd_data; /* LLD private data */ | 146 | void *dd_data; /* LLD private data */ |
@@ -129,6 +164,12 @@ struct iscsi_cls_conn { | |||
129 | #define iscsi_dev_to_conn(_dev) \ | 164 | #define iscsi_dev_to_conn(_dev) \ |
130 | container_of(_dev, struct iscsi_cls_conn, dev) | 165 | container_of(_dev, struct iscsi_cls_conn, dev) |
131 | 166 | ||
167 | /* Session's states */ | ||
168 | #define ISCSI_STATE_FREE 1 | ||
169 | #define ISCSI_STATE_LOGGED_IN 2 | ||
170 | #define ISCSI_STATE_FAILED 3 | ||
171 | #define ISCSI_STATE_TERMINATE 4 | ||
172 | |||
132 | struct iscsi_cls_session { | 173 | struct iscsi_cls_session { |
133 | struct list_head sess_list; /* item in session_list */ | 174 | struct list_head sess_list; /* item in session_list */ |
134 | struct list_head host_list; | 175 | struct list_head host_list; |
@@ -174,12 +215,4 @@ extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); | |||
174 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); | 215 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); |
175 | extern void iscsi_block_session(struct iscsi_cls_session *session); | 216 | extern void iscsi_block_session(struct iscsi_cls_session *session); |
176 | 217 | ||
177 | /* | ||
178 | * session functions used by software iscsi | ||
179 | */ | ||
180 | extern struct Scsi_Host * | ||
181 | iscsi_transport_create_session(struct scsi_transport_template *scsit, | ||
182 | struct iscsi_transport *transport); | ||
183 | extern int iscsi_transport_destroy_session(struct Scsi_Host *shost); | ||
184 | |||
185 | #endif | 218 | #endif |