diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/scsi/iscsi_if.h | 245 | ||||
-rw-r--r-- | include/scsi/iscsi_proto.h | 589 | ||||
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 202 |
3 files changed, 889 insertions, 147 deletions
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h new file mode 100644 index 000000000000..be1bc792ab18 --- /dev/null +++ b/include/scsi/iscsi_if.h | |||
@@ -0,0 +1,245 @@ | |||
1 | /* | ||
2 | * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc) | ||
3 | * | ||
4 | * Copyright (C) 2005 Dmitry Yusupov | ||
5 | * Copyright (C) 2005 Alex Aizman | ||
6 | * maintained by open-iscsi@googlegroups.com | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published | ||
10 | * by the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * See the file COPYING included with this distribution for more details. | ||
19 | */ | ||
20 | |||
21 | #ifndef ISCSI_IF_H | ||
22 | #define ISCSI_IF_H | ||
23 | |||
24 | #include <scsi/iscsi_proto.h> | ||
25 | |||
26 | #define UEVENT_BASE 10 | ||
27 | #define KEVENT_BASE 100 | ||
28 | #define ISCSI_ERR_BASE 1000 | ||
29 | |||
30 | enum iscsi_uevent_e { | ||
31 | ISCSI_UEVENT_UNKNOWN = 0, | ||
32 | |||
33 | /* down events */ | ||
34 | ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1, | ||
35 | ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2, | ||
36 | ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3, | ||
37 | ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4, | ||
38 | ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5, | ||
39 | ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6, | ||
40 | ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7, | ||
41 | ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8, | ||
42 | ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9, | ||
43 | ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10, | ||
44 | ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11, | ||
45 | |||
46 | /* up events */ | ||
47 | ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, | ||
48 | ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2, | ||
49 | ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3, | ||
50 | }; | ||
51 | |||
52 | struct iscsi_uevent { | ||
53 | uint32_t type; /* k/u events type */ | ||
54 | uint32_t iferror; /* carries interface or resource errors */ | ||
55 | uint64_t transport_handle; | ||
56 | |||
57 | union { | ||
58 | /* messages u -> k */ | ||
59 | struct msg_create_session { | ||
60 | uint32_t initial_cmdsn; | ||
61 | } c_session; | ||
62 | struct msg_destroy_session { | ||
63 | uint64_t session_handle; | ||
64 | uint32_t sid; | ||
65 | } d_session; | ||
66 | struct msg_create_conn { | ||
67 | uint64_t session_handle; | ||
68 | uint32_t cid; | ||
69 | uint32_t sid; | ||
70 | } c_conn; | ||
71 | struct msg_bind_conn { | ||
72 | uint64_t session_handle; | ||
73 | uint64_t conn_handle; | ||
74 | uint32_t transport_fd; | ||
75 | uint32_t is_leading; | ||
76 | } b_conn; | ||
77 | struct msg_destroy_conn { | ||
78 | uint64_t conn_handle; | ||
79 | uint32_t cid; | ||
80 | } d_conn; | ||
81 | struct msg_send_pdu { | ||
82 | uint32_t hdr_size; | ||
83 | uint32_t data_size; | ||
84 | uint64_t conn_handle; | ||
85 | } send_pdu; | ||
86 | struct msg_set_param { | ||
87 | uint64_t conn_handle; | ||
88 | uint32_t param; /* enum iscsi_param */ | ||
89 | uint32_t value; | ||
90 | } set_param; | ||
91 | struct msg_start_conn { | ||
92 | uint64_t conn_handle; | ||
93 | } start_conn; | ||
94 | struct msg_stop_conn { | ||
95 | uint64_t conn_handle; | ||
96 | uint32_t flag; | ||
97 | } stop_conn; | ||
98 | struct msg_get_stats { | ||
99 | uint64_t conn_handle; | ||
100 | } get_stats; | ||
101 | } u; | ||
102 | union { | ||
103 | /* messages k -> u */ | ||
104 | uint64_t handle; | ||
105 | int retcode; | ||
106 | struct msg_create_session_ret { | ||
107 | uint64_t session_handle; | ||
108 | uint32_t sid; | ||
109 | } c_session_ret; | ||
110 | struct msg_recv_req { | ||
111 | uint64_t recv_handle; | ||
112 | uint64_t conn_handle; | ||
113 | } recv_req; | ||
114 | struct msg_conn_error { | ||
115 | uint64_t conn_handle; | ||
116 | uint32_t error; /* enum iscsi_err */ | ||
117 | } connerror; | ||
118 | } r; | ||
119 | } __attribute__ ((aligned (sizeof(uint64_t)))); | ||
120 | |||
121 | /* | ||
122 | * Common error codes | ||
123 | */ | ||
124 | enum iscsi_err { | ||
125 | ISCSI_OK = 0, | ||
126 | |||
127 | ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1, | ||
128 | ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2, | ||
129 | ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3, | ||
130 | ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4, | ||
131 | ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5, | ||
132 | ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6, | ||
133 | ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7, | ||
134 | ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8, | ||
135 | ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9, | ||
136 | ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10, | ||
137 | ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11, | ||
138 | ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12, | ||
139 | ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13, | ||
140 | ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14, | ||
141 | ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, | ||
142 | ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16 | ||
143 | }; | ||
144 | |||
145 | /* | ||
146 | * iSCSI Parameters (RFC3720) | ||
147 | */ | ||
148 | enum iscsi_param { | ||
149 | ISCSI_PARAM_MAX_RECV_DLENGTH = 0, | ||
150 | ISCSI_PARAM_MAX_XMIT_DLENGTH = 1, | ||
151 | ISCSI_PARAM_HDRDGST_EN = 2, | ||
152 | ISCSI_PARAM_DATADGST_EN = 3, | ||
153 | ISCSI_PARAM_INITIAL_R2T_EN = 4, | ||
154 | ISCSI_PARAM_MAX_R2T = 5, | ||
155 | ISCSI_PARAM_IMM_DATA_EN = 6, | ||
156 | ISCSI_PARAM_FIRST_BURST = 7, | ||
157 | ISCSI_PARAM_MAX_BURST = 8, | ||
158 | ISCSI_PARAM_PDU_INORDER_EN = 9, | ||
159 | ISCSI_PARAM_DATASEQ_INORDER_EN = 10, | ||
160 | ISCSI_PARAM_ERL = 11, | ||
161 | ISCSI_PARAM_IFMARKER_EN = 12, | ||
162 | ISCSI_PARAM_OFMARKER_EN = 13, | ||
163 | }; | ||
164 | #define ISCSI_PARAM_MAX 14 | ||
165 | |||
166 | typedef uint64_t iscsi_sessionh_t; /* iSCSI Data-Path session handle */ | ||
167 | typedef uint64_t iscsi_connh_t; /* iSCSI Data-Path connection handle */ | ||
168 | |||
169 | #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) | ||
170 | #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) | ||
171 | #define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long)) | ||
172 | |||
173 | /* | ||
174 | * These flags presents iSCSI Data-Path capabilities. | ||
175 | */ | ||
176 | #define CAP_RECOVERY_L0 0x1 | ||
177 | #define CAP_RECOVERY_L1 0x2 | ||
178 | #define CAP_RECOVERY_L2 0x4 | ||
179 | #define CAP_MULTI_R2T 0x8 | ||
180 | #define CAP_HDRDGST 0x10 | ||
181 | #define CAP_DATADGST 0x20 | ||
182 | #define CAP_MULTI_CONN 0x40 | ||
183 | #define CAP_TEXT_NEGO 0x80 | ||
184 | #define CAP_MARKERS 0x100 | ||
185 | |||
186 | /* | ||
187 | * These flags describes reason of stop_conn() call | ||
188 | */ | ||
189 | #define STOP_CONN_TERM 0x1 | ||
190 | #define STOP_CONN_SUSPEND 0x2 | ||
191 | #define STOP_CONN_RECOVER 0x3 | ||
192 | |||
193 | #define ISCSI_STATS_CUSTOM_MAX 32 | ||
194 | #define ISCSI_STATS_CUSTOM_DESC_MAX 64 | ||
195 | struct iscsi_stats_custom { | ||
196 | char desc[ISCSI_STATS_CUSTOM_DESC_MAX]; | ||
197 | uint64_t value; | ||
198 | }; | ||
199 | |||
200 | /* | ||
201 | * struct iscsi_stats - iSCSI Statistics (iSCSI MIB) | ||
202 | * | ||
203 | * Note: this structure contains counters collected on per-connection basis. | ||
204 | */ | ||
205 | struct iscsi_stats { | ||
206 | /* octets */ | ||
207 | uint64_t txdata_octets; | ||
208 | uint64_t rxdata_octets; | ||
209 | |||
210 | /* xmit pdus */ | ||
211 | uint32_t noptx_pdus; | ||
212 | uint32_t scsicmd_pdus; | ||
213 | uint32_t tmfcmd_pdus; | ||
214 | uint32_t login_pdus; | ||
215 | uint32_t text_pdus; | ||
216 | uint32_t dataout_pdus; | ||
217 | uint32_t logout_pdus; | ||
218 | uint32_t snack_pdus; | ||
219 | |||
220 | /* recv pdus */ | ||
221 | uint32_t noprx_pdus; | ||
222 | uint32_t scsirsp_pdus; | ||
223 | uint32_t tmfrsp_pdus; | ||
224 | uint32_t textrsp_pdus; | ||
225 | uint32_t datain_pdus; | ||
226 | uint32_t logoutrsp_pdus; | ||
227 | uint32_t r2t_pdus; | ||
228 | uint32_t async_pdus; | ||
229 | uint32_t rjt_pdus; | ||
230 | |||
231 | /* errors */ | ||
232 | uint32_t digest_err; | ||
233 | uint32_t timeout_err; | ||
234 | |||
235 | /* | ||
236 | * iSCSI Custom Statistics support, i.e. Transport could | ||
237 | * extend existing MIB statistics with its own specific statistics | ||
238 | * up to ISCSI_STATS_CUSTOM_MAX | ||
239 | */ | ||
240 | uint32_t custom_length; | ||
241 | struct iscsi_stats_custom custom[0] | ||
242 | __attribute__ ((aligned (sizeof(uint64_t)))); | ||
243 | }; | ||
244 | |||
245 | #endif | ||
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h new file mode 100644 index 000000000000..4feda05fdf25 --- /dev/null +++ b/include/scsi/iscsi_proto.h | |||
@@ -0,0 +1,589 @@ | |||
1 | /* | ||
2 | * RFC 3720 (iSCSI) protocol data types | ||
3 | * | ||
4 | * Copyright (C) 2005 Dmitry Yusupov | ||
5 | * Copyright (C) 2005 Alex Aizman | ||
6 | * maintained by open-iscsi@googlegroups.com | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published | ||
10 | * by the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * See the file COPYING included with this distribution for more details. | ||
19 | */ | ||
20 | |||
21 | #ifndef ISCSI_PROTO_H | ||
22 | #define ISCSI_PROTO_H | ||
23 | |||
24 | #define ISCSI_VERSION_STR "0.3" | ||
25 | #define ISCSI_DATE_STR "22-Apr-2005" | ||
26 | #define ISCSI_DRAFT20_VERSION 0x00 | ||
27 | |||
28 | /* default iSCSI listen port for incoming connections */ | ||
29 | #define ISCSI_LISTEN_PORT 3260 | ||
30 | |||
31 | /* Padding word length */ | ||
32 | #define PAD_WORD_LEN 4 | ||
33 | |||
34 | /* | ||
35 | * useful common(control and data pathes) macro | ||
36 | */ | ||
37 | #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) | ||
38 | #define hton24(p, v) { \ | ||
39 | p[0] = (((v) >> 16) & 0xFF); \ | ||
40 | p[1] = (((v) >> 8) & 0xFF); \ | ||
41 | p[2] = ((v) & 0xFF); \ | ||
42 | } | ||
43 | #define zero_data(p) {p[0]=0;p[1]=0;p[2]=0;} | ||
44 | |||
45 | /* | ||
46 | * iSCSI Template Message Header | ||
47 | */ | ||
48 | struct iscsi_hdr { | ||
49 | uint8_t opcode; | ||
50 | uint8_t flags; /* Final bit */ | ||
51 | uint8_t rsvd2[2]; | ||
52 | uint8_t hlength; /* AHSs total length */ | ||
53 | uint8_t dlength[3]; /* Data length */ | ||
54 | uint8_t lun[8]; | ||
55 | __be32 itt; /* Initiator Task Tag */ | ||
56 | __be32 ttt; /* Target Task Tag */ | ||
57 | __be32 statsn; | ||
58 | __be32 exp_statsn; | ||
59 | __be32 max_statsn; | ||
60 | uint8_t other[12]; | ||
61 | }; | ||
62 | |||
63 | /************************* RFC 3720 Begin *****************************/ | ||
64 | |||
65 | #define ISCSI_RESERVED_TAG 0xffffffff | ||
66 | |||
67 | /* Opcode encoding bits */ | ||
68 | #define ISCSI_OP_RETRY 0x80 | ||
69 | #define ISCSI_OP_IMMEDIATE 0x40 | ||
70 | #define ISCSI_OPCODE_MASK 0x3F | ||
71 | |||
72 | /* Initiator Opcode values */ | ||
73 | #define ISCSI_OP_NOOP_OUT 0x00 | ||
74 | #define ISCSI_OP_SCSI_CMD 0x01 | ||
75 | #define ISCSI_OP_SCSI_TMFUNC 0x02 | ||
76 | #define ISCSI_OP_LOGIN 0x03 | ||
77 | #define ISCSI_OP_TEXT 0x04 | ||
78 | #define ISCSI_OP_SCSI_DATA_OUT 0x05 | ||
79 | #define ISCSI_OP_LOGOUT 0x06 | ||
80 | #define ISCSI_OP_SNACK 0x10 | ||
81 | |||
82 | #define ISCSI_OP_VENDOR1_CMD 0x1c | ||
83 | #define ISCSI_OP_VENDOR2_CMD 0x1d | ||
84 | #define ISCSI_OP_VENDOR3_CMD 0x1e | ||
85 | #define ISCSI_OP_VENDOR4_CMD 0x1f | ||
86 | |||
87 | /* Target Opcode values */ | ||
88 | #define ISCSI_OP_NOOP_IN 0x20 | ||
89 | #define ISCSI_OP_SCSI_CMD_RSP 0x21 | ||
90 | #define ISCSI_OP_SCSI_TMFUNC_RSP 0x22 | ||
91 | #define ISCSI_OP_LOGIN_RSP 0x23 | ||
92 | #define ISCSI_OP_TEXT_RSP 0x24 | ||
93 | #define ISCSI_OP_SCSI_DATA_IN 0x25 | ||
94 | #define ISCSI_OP_LOGOUT_RSP 0x26 | ||
95 | #define ISCSI_OP_R2T 0x31 | ||
96 | #define ISCSI_OP_ASYNC_EVENT 0x32 | ||
97 | #define ISCSI_OP_REJECT 0x3f | ||
98 | |||
99 | struct iscsi_ahs_hdr { | ||
100 | __be16 ahslength; | ||
101 | uint8_t ahstype; | ||
102 | uint8_t ahspec[5]; | ||
103 | }; | ||
104 | |||
105 | #define ISCSI_AHSTYPE_CDB 1 | ||
106 | #define ISCSI_AHSTYPE_RLENGTH 2 | ||
107 | |||
108 | /* iSCSI PDU Header */ | ||
109 | struct iscsi_cmd { | ||
110 | uint8_t opcode; | ||
111 | uint8_t flags; | ||
112 | __be16 rsvd2; | ||
113 | uint8_t hlength; | ||
114 | uint8_t dlength[3]; | ||
115 | uint8_t lun[8]; | ||
116 | __be32 itt; /* Initiator Task Tag */ | ||
117 | __be32 data_length; | ||
118 | __be32 cmdsn; | ||
119 | __be32 exp_statsn; | ||
120 | uint8_t cdb[16]; /* SCSI Command Block */ | ||
121 | /* Additional Data (Command Dependent) */ | ||
122 | }; | ||
123 | |||
124 | /* Command PDU flags */ | ||
125 | #define ISCSI_FLAG_CMD_FINAL 0x80 | ||
126 | #define ISCSI_FLAG_CMD_READ 0x40 | ||
127 | #define ISCSI_FLAG_CMD_WRITE 0x20 | ||
128 | #define ISCSI_FLAG_CMD_ATTR_MASK 0x07 /* 3 bits */ | ||
129 | |||
130 | /* SCSI Command Attribute values */ | ||
131 | #define ISCSI_ATTR_UNTAGGED 0 | ||
132 | #define ISCSI_ATTR_SIMPLE 1 | ||
133 | #define ISCSI_ATTR_ORDERED 2 | ||
134 | #define ISCSI_ATTR_HEAD_OF_QUEUE 3 | ||
135 | #define ISCSI_ATTR_ACA 4 | ||
136 | |||
137 | struct iscsi_rlength_ahdr { | ||
138 | __be16 ahslength; | ||
139 | uint8_t ahstype; | ||
140 | uint8_t reserved; | ||
141 | __be32 read_length; | ||
142 | }; | ||
143 | |||
144 | /* SCSI Response Header */ | ||
145 | struct iscsi_cmd_rsp { | ||
146 | uint8_t opcode; | ||
147 | uint8_t flags; | ||
148 | uint8_t response; | ||
149 | uint8_t cmd_status; | ||
150 | uint8_t hlength; | ||
151 | uint8_t dlength[3]; | ||
152 | uint8_t rsvd[8]; | ||
153 | __be32 itt; /* Initiator Task Tag */ | ||
154 | __be32 rsvd1; | ||
155 | __be32 statsn; | ||
156 | __be32 exp_cmdsn; | ||
157 | __be32 max_cmdsn; | ||
158 | __be32 exp_datasn; | ||
159 | __be32 bi_residual_count; | ||
160 | __be32 residual_count; | ||
161 | /* Response or Sense Data (optional) */ | ||
162 | }; | ||
163 | |||
164 | /* Command Response PDU flags */ | ||
165 | #define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10 | ||
166 | #define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08 | ||
167 | #define ISCSI_FLAG_CMD_OVERFLOW 0x04 | ||
168 | #define ISCSI_FLAG_CMD_UNDERFLOW 0x02 | ||
169 | |||
170 | /* iSCSI Status values. Valid if Rsp Selector bit is not set */ | ||
171 | #define ISCSI_STATUS_CMD_COMPLETED 0 | ||
172 | #define ISCSI_STATUS_TARGET_FAILURE 1 | ||
173 | #define ISCSI_STATUS_SUBSYS_FAILURE 2 | ||
174 | |||
175 | /* Asynchronous Event Header */ | ||
176 | struct iscsi_async { | ||
177 | uint8_t opcode; | ||
178 | uint8_t flags; | ||
179 | uint8_t rsvd2[2]; | ||
180 | uint8_t rsvd3; | ||
181 | uint8_t dlength[3]; | ||
182 | uint8_t lun[8]; | ||
183 | uint8_t rsvd4[8]; | ||
184 | __be32 statsn; | ||
185 | __be32 exp_cmdsn; | ||
186 | __be32 max_cmdsn; | ||
187 | uint8_t async_event; | ||
188 | uint8_t async_vcode; | ||
189 | __be16 param1; | ||
190 | __be16 param2; | ||
191 | __be16 param3; | ||
192 | uint8_t rsvd5[4]; | ||
193 | }; | ||
194 | |||
195 | /* iSCSI Event Codes */ | ||
196 | #define ISCSI_ASYNC_MSG_SCSI_EVENT 0 | ||
197 | #define ISCSI_ASYNC_MSG_REQUEST_LOGOUT 1 | ||
198 | #define ISCSI_ASYNC_MSG_DROPPING_CONNECTION 2 | ||
199 | #define ISCSI_ASYNC_MSG_DROPPING_ALL_CONNECTIONS 3 | ||
200 | #define ISCSI_ASYNC_MSG_PARAM_NEGOTIATION 4 | ||
201 | #define ISCSI_ASYNC_MSG_VENDOR_SPECIFIC 255 | ||
202 | |||
203 | /* NOP-Out Message */ | ||
204 | struct iscsi_nopout { | ||
205 | uint8_t opcode; | ||
206 | uint8_t flags; | ||
207 | __be16 rsvd2; | ||
208 | uint8_t rsvd3; | ||
209 | uint8_t dlength[3]; | ||
210 | uint8_t lun[8]; | ||
211 | __be32 itt; /* Initiator Task Tag */ | ||
212 | __be32 ttt; /* Target Transfer Tag */ | ||
213 | __be32 cmdsn; | ||
214 | __be32 exp_statsn; | ||
215 | uint8_t rsvd4[16]; | ||
216 | }; | ||
217 | |||
218 | /* NOP-In Message */ | ||
219 | struct iscsi_nopin { | ||
220 | uint8_t opcode; | ||
221 | uint8_t flags; | ||
222 | __be16 rsvd2; | ||
223 | uint8_t rsvd3; | ||
224 | uint8_t dlength[3]; | ||
225 | uint8_t lun[8]; | ||
226 | __be32 itt; /* Initiator Task Tag */ | ||
227 | __be32 ttt; /* Target Transfer Tag */ | ||
228 | __be32 statsn; | ||
229 | __be32 exp_cmdsn; | ||
230 | __be32 max_cmdsn; | ||
231 | uint8_t rsvd4[12]; | ||
232 | }; | ||
233 | |||
234 | /* SCSI Task Management Message Header */ | ||
235 | struct iscsi_tm { | ||
236 | uint8_t opcode; | ||
237 | uint8_t flags; | ||
238 | uint8_t rsvd1[2]; | ||
239 | uint8_t hlength; | ||
240 | uint8_t dlength[3]; | ||
241 | uint8_t lun[8]; | ||
242 | __be32 itt; /* Initiator Task Tag */ | ||
243 | __be32 rtt; /* Reference Task Tag */ | ||
244 | __be32 cmdsn; | ||
245 | __be32 exp_statsn; | ||
246 | __be32 refcmdsn; | ||
247 | __be32 exp_datasn; | ||
248 | uint8_t rsvd2[8]; | ||
249 | }; | ||
250 | |||
251 | #define ISCSI_FLAG_TM_FUNC_MASK 0x7F | ||
252 | |||
253 | /* Function values */ | ||
254 | #define ISCSI_TM_FUNC_ABORT_TASK 1 | ||
255 | #define ISCSI_TM_FUNC_ABORT_TASK_SET 2 | ||
256 | #define ISCSI_TM_FUNC_CLEAR_ACA 3 | ||
257 | #define ISCSI_TM_FUNC_CLEAR_TASK_SET 4 | ||
258 | #define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5 | ||
259 | #define ISCSI_TM_FUNC_TARGET_WARM_RESET 6 | ||
260 | #define ISCSI_TM_FUNC_TARGET_COLD_RESET 7 | ||
261 | #define ISCSI_TM_FUNC_TASK_REASSIGN 8 | ||
262 | |||
263 | /* SCSI Task Management Response Header */ | ||
264 | struct iscsi_tm_rsp { | ||
265 | uint8_t opcode; | ||
266 | uint8_t flags; | ||
267 | uint8_t response; /* see Response values below */ | ||
268 | uint8_t qualifier; | ||
269 | uint8_t hlength; | ||
270 | uint8_t dlength[3]; | ||
271 | uint8_t rsvd2[8]; | ||
272 | __be32 itt; /* Initiator Task Tag */ | ||
273 | __be32 rtt; /* Reference Task Tag */ | ||
274 | __be32 statsn; | ||
275 | __be32 exp_cmdsn; | ||
276 | __be32 max_cmdsn; | ||
277 | uint8_t rsvd3[12]; | ||
278 | }; | ||
279 | |||
280 | /* Response values */ | ||
281 | #define ISCSI_TMF_RSP_COMPLETE 0x00 | ||
282 | #define ISCSI_TMF_RSP_NO_TASK 0x01 | ||
283 | #define ISCSI_TMF_RSP_NO_LUN 0x02 | ||
284 | #define ISCSI_TMF_RSP_TASK_ALLEGIANT 0x03 | ||
285 | #define ISCSI_TMF_RSP_NO_FAILOVER 0x04 | ||
286 | #define ISCSI_TMF_RSP_NOT_SUPPORTED 0x05 | ||
287 | #define ISCSI_TMF_RSP_AUTH_FAILED 0x06 | ||
288 | #define ISCSI_TMF_RSP_REJECTED 0xff | ||
289 | |||
290 | /* Ready To Transfer Header */ | ||
291 | struct iscsi_r2t_rsp { | ||
292 | uint8_t opcode; | ||
293 | uint8_t flags; | ||
294 | uint8_t rsvd2[2]; | ||
295 | uint8_t hlength; | ||
296 | uint8_t dlength[3]; | ||
297 | uint8_t lun[8]; | ||
298 | __be32 itt; /* Initiator Task Tag */ | ||
299 | __be32 ttt; /* Target Transfer Tag */ | ||
300 | __be32 statsn; | ||
301 | __be32 exp_cmdsn; | ||
302 | __be32 max_cmdsn; | ||
303 | __be32 r2tsn; | ||
304 | __be32 data_offset; | ||
305 | __be32 data_length; | ||
306 | }; | ||
307 | |||
308 | /* SCSI Data Hdr */ | ||
309 | struct iscsi_data { | ||
310 | uint8_t opcode; | ||
311 | uint8_t flags; | ||
312 | uint8_t rsvd2[2]; | ||
313 | uint8_t rsvd3; | ||
314 | uint8_t dlength[3]; | ||
315 | uint8_t lun[8]; | ||
316 | __be32 itt; | ||
317 | __be32 ttt; | ||
318 | __be32 rsvd4; | ||
319 | __be32 exp_statsn; | ||
320 | __be32 rsvd5; | ||
321 | __be32 datasn; | ||
322 | __be32 offset; | ||
323 | __be32 rsvd6; | ||
324 | /* Payload */ | ||
325 | }; | ||
326 | |||
327 | /* SCSI Data Response Hdr */ | ||
328 | struct iscsi_data_rsp { | ||
329 | uint8_t opcode; | ||
330 | uint8_t flags; | ||
331 | uint8_t rsvd2; | ||
332 | uint8_t cmd_status; | ||
333 | uint8_t hlength; | ||
334 | uint8_t dlength[3]; | ||
335 | uint8_t lun[8]; | ||
336 | __be32 itt; | ||
337 | __be32 ttt; | ||
338 | __be32 statsn; | ||
339 | __be32 exp_cmdsn; | ||
340 | __be32 max_cmdsn; | ||
341 | __be32 datasn; | ||
342 | __be32 offset; | ||
343 | __be32 residual_count; | ||
344 | }; | ||
345 | |||
346 | /* Data Response PDU flags */ | ||
347 | #define ISCSI_FLAG_DATA_ACK 0x40 | ||
348 | #define ISCSI_FLAG_DATA_OVERFLOW 0x04 | ||
349 | #define ISCSI_FLAG_DATA_UNDERFLOW 0x02 | ||
350 | #define ISCSI_FLAG_DATA_STATUS 0x01 | ||
351 | |||
352 | /* Text Header */ | ||
353 | struct iscsi_text { | ||
354 | uint8_t opcode; | ||
355 | uint8_t flags; | ||
356 | uint8_t rsvd2[2]; | ||
357 | uint8_t hlength; | ||
358 | uint8_t dlength[3]; | ||
359 | uint8_t rsvd4[8]; | ||
360 | __be32 itt; | ||
361 | __be32 ttt; | ||
362 | __be32 cmdsn; | ||
363 | __be32 exp_statsn; | ||
364 | uint8_t rsvd5[16]; | ||
365 | /* Text - key=value pairs */ | ||
366 | }; | ||
367 | |||
368 | #define ISCSI_FLAG_TEXT_CONTINUE 0x40 | ||
369 | |||
370 | /* Text Response Header */ | ||
371 | struct iscsi_text_rsp { | ||
372 | uint8_t opcode; | ||
373 | uint8_t flags; | ||
374 | uint8_t rsvd2[2]; | ||
375 | uint8_t hlength; | ||
376 | uint8_t dlength[3]; | ||
377 | uint8_t rsvd4[8]; | ||
378 | __be32 itt; | ||
379 | __be32 ttt; | ||
380 | __be32 statsn; | ||
381 | __be32 exp_cmdsn; | ||
382 | __be32 max_cmdsn; | ||
383 | uint8_t rsvd5[12]; | ||
384 | /* Text Response - key:value pairs */ | ||
385 | }; | ||
386 | |||
387 | /* Login Header */ | ||
388 | struct iscsi_login { | ||
389 | uint8_t opcode; | ||
390 | uint8_t flags; | ||
391 | uint8_t max_version; /* Max. version supported */ | ||
392 | uint8_t min_version; /* Min. version supported */ | ||
393 | uint8_t hlength; | ||
394 | uint8_t dlength[3]; | ||
395 | uint8_t isid[6]; /* Initiator Session ID */ | ||
396 | __be16 tsih; /* Target Session Handle */ | ||
397 | __be32 itt; /* Initiator Task Tag */ | ||
398 | __be16 cid; | ||
399 | __be16 rsvd3; | ||
400 | __be32 cmdsn; | ||
401 | __be32 exp_statsn; | ||
402 | uint8_t rsvd5[16]; | ||
403 | }; | ||
404 | |||
405 | /* Login PDU flags */ | ||
406 | #define ISCSI_FLAG_LOGIN_TRANSIT 0x80 | ||
407 | #define ISCSI_FLAG_LOGIN_CONTINUE 0x40 | ||
408 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */ | ||
409 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */ | ||
410 | |||
411 | #define ISCSI_LOGIN_CURRENT_STAGE(flags) \ | ||
412 | ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2) | ||
413 | #define ISCSI_LOGIN_NEXT_STAGE(flags) \ | ||
414 | (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK) | ||
415 | |||
416 | /* Login Response Header */ | ||
417 | struct iscsi_login_rsp { | ||
418 | uint8_t opcode; | ||
419 | uint8_t flags; | ||
420 | uint8_t max_version; /* Max. version supported */ | ||
421 | uint8_t active_version; /* Active version */ | ||
422 | uint8_t hlength; | ||
423 | uint8_t dlength[3]; | ||
424 | uint8_t isid[6]; /* Initiator Session ID */ | ||
425 | __be16 tsih; /* Target Session Handle */ | ||
426 | __be32 itt; /* Initiator Task Tag */ | ||
427 | __be32 rsvd3; | ||
428 | __be32 statsn; | ||
429 | __be32 exp_cmdsn; | ||
430 | __be32 max_cmdsn; | ||
431 | uint8_t status_class; /* see Login RSP ststus classes below */ | ||
432 | uint8_t status_detail; /* see Login RSP Status details below */ | ||
433 | uint8_t rsvd4[10]; | ||
434 | }; | ||
435 | |||
436 | /* Login stage (phase) codes for CSG, NSG */ | ||
437 | #define ISCSI_INITIAL_LOGIN_STAGE -1 | ||
438 | #define ISCSI_SECURITY_NEGOTIATION_STAGE 0 | ||
439 | #define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1 | ||
440 | #define ISCSI_FULL_FEATURE_PHASE 3 | ||
441 | |||
442 | /* Login Status response classes */ | ||
443 | #define ISCSI_STATUS_CLS_SUCCESS 0x00 | ||
444 | #define ISCSI_STATUS_CLS_REDIRECT 0x01 | ||
445 | #define ISCSI_STATUS_CLS_INITIATOR_ERR 0x02 | ||
446 | #define ISCSI_STATUS_CLS_TARGET_ERR 0x03 | ||
447 | |||
448 | /* Login Status response detail codes */ | ||
449 | /* Class-0 (Success) */ | ||
450 | #define ISCSI_LOGIN_STATUS_ACCEPT 0x00 | ||
451 | |||
452 | /* Class-1 (Redirection) */ | ||
453 | #define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01 | ||
454 | #define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02 | ||
455 | |||
456 | /* Class-2 (Initiator Error) */ | ||
457 | #define ISCSI_LOGIN_STATUS_INIT_ERR 0x00 | ||
458 | #define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01 | ||
459 | #define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02 | ||
460 | #define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03 | ||
461 | #define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04 | ||
462 | #define ISCSI_LOGIN_STATUS_NO_VERSION 0x05 | ||
463 | #define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06 | ||
464 | #define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07 | ||
465 | #define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08 | ||
466 | #define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09 | ||
467 | #define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a | ||
468 | #define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b | ||
469 | |||
470 | /* Class-3 (Target Error) */ | ||
471 | #define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00 | ||
472 | #define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01 | ||
473 | #define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02 | ||
474 | |||
475 | /* Logout Header */ | ||
476 | struct iscsi_logout { | ||
477 | uint8_t opcode; | ||
478 | uint8_t flags; | ||
479 | uint8_t rsvd1[2]; | ||
480 | uint8_t hlength; | ||
481 | uint8_t dlength[3]; | ||
482 | uint8_t rsvd2[8]; | ||
483 | __be32 itt; /* Initiator Task Tag */ | ||
484 | __be16 cid; | ||
485 | uint8_t rsvd3[2]; | ||
486 | __be32 cmdsn; | ||
487 | __be32 exp_statsn; | ||
488 | uint8_t rsvd4[16]; | ||
489 | }; | ||
490 | |||
491 | /* Logout PDU flags */ | ||
492 | #define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F | ||
493 | |||
494 | /* logout reason_code values */ | ||
495 | |||
496 | #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0 | ||
497 | #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1 | ||
498 | #define ISCSI_LOGOUT_REASON_RECOVERY 2 | ||
499 | #define ISCSI_LOGOUT_REASON_AEN_REQUEST 3 | ||
500 | |||
501 | /* Logout Response Header */ | ||
502 | struct iscsi_logout_rsp { | ||
503 | uint8_t opcode; | ||
504 | uint8_t flags; | ||
505 | uint8_t response; /* see Logout response values below */ | ||
506 | uint8_t rsvd2; | ||
507 | uint8_t hlength; | ||
508 | uint8_t dlength[3]; | ||
509 | uint8_t rsvd3[8]; | ||
510 | __be32 itt; /* Initiator Task Tag */ | ||
511 | __be32 rsvd4; | ||
512 | __be32 statsn; | ||
513 | __be32 exp_cmdsn; | ||
514 | __be32 max_cmdsn; | ||
515 | __be32 rsvd5; | ||
516 | __be16 t2wait; | ||
517 | __be16 t2retain; | ||
518 | __be32 rsvd6; | ||
519 | }; | ||
520 | |||
521 | /* logout response status values */ | ||
522 | |||
523 | #define ISCSI_LOGOUT_SUCCESS 0 | ||
524 | #define ISCSI_LOGOUT_CID_NOT_FOUND 1 | ||
525 | #define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2 | ||
526 | #define ISCSI_LOGOUT_CLEANUP_FAILED 3 | ||
527 | |||
528 | /* SNACK Header */ | ||
529 | struct iscsi_snack { | ||
530 | uint8_t opcode; | ||
531 | uint8_t flags; | ||
532 | uint8_t rsvd2[14]; | ||
533 | __be32 itt; | ||
534 | __be32 begrun; | ||
535 | __be32 runlength; | ||
536 | __be32 exp_statsn; | ||
537 | __be32 rsvd3; | ||
538 | __be32 exp_datasn; | ||
539 | uint8_t rsvd6[8]; | ||
540 | }; | ||
541 | |||
542 | /* SNACK PDU flags */ | ||
543 | #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */ | ||
544 | |||
545 | /* Reject Message Header */ | ||
546 | struct iscsi_reject { | ||
547 | uint8_t opcode; | ||
548 | uint8_t flags; | ||
549 | uint8_t reason; | ||
550 | uint8_t rsvd2; | ||
551 | uint8_t hlength; | ||
552 | uint8_t dlength[3]; | ||
553 | uint8_t rsvd3[8]; | ||
554 | __be32 ffffffff; | ||
555 | uint8_t rsvd4[4]; | ||
556 | __be32 statsn; | ||
557 | __be32 exp_cmdsn; | ||
558 | __be32 max_cmdsn; | ||
559 | __be32 datasn; | ||
560 | uint8_t rsvd5[8]; | ||
561 | /* Text - Rejected hdr */ | ||
562 | }; | ||
563 | |||
564 | /* Reason for Reject */ | ||
565 | #define ISCSI_REASON_CMD_BEFORE_LOGIN 1 | ||
566 | #define ISCSI_REASON_DATA_DIGEST_ERROR 2 | ||
567 | #define ISCSI_REASON_DATA_SNACK_REJECT 3 | ||
568 | #define ISCSI_REASON_PROTOCOL_ERROR 4 | ||
569 | #define ISCSI_REASON_CMD_NOT_SUPPORTED 5 | ||
570 | #define ISCSI_REASON_IMM_CMD_REJECT 6 | ||
571 | #define ISCSI_REASON_TASK_IN_PROGRESS 7 | ||
572 | #define ISCSI_REASON_INVALID_SNACK 8 | ||
573 | #define ISCSI_REASON_BOOKMARK_INVALID 9 | ||
574 | #define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10 | ||
575 | #define ISCSI_REASON_NEGOTIATION_RESET 11 | ||
576 | |||
577 | /* Max. number of Key=Value pairs in a text message */ | ||
578 | #define MAX_KEY_VALUE_PAIRS 8192 | ||
579 | |||
580 | /* maximum length for text keys/values */ | ||
581 | #define KEY_MAXLEN 64 | ||
582 | #define VALUE_MAXLEN 255 | ||
583 | #define TARGET_NAME_MAXLEN VALUE_MAXLEN | ||
584 | |||
585 | #define DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192 | ||
586 | |||
587 | /************************* RFC 3720 End *****************************/ | ||
588 | |||
589 | #endif /* ISCSI_PROTO_H */ | ||
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 1b26a6c0aa2a..f25041c386ec 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -1,8 +1,10 @@ | |||
1 | /* | 1 | /* |
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 | 5 | * Copyright (C) Mike Christie, 2004 - 2005 |
6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 | ||
7 | * Copyright (C) Alex Aizman, 2004 - 2005 | ||
6 | * | 8 | * |
7 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,158 +23,64 @@ | |||
21 | #ifndef SCSI_TRANSPORT_ISCSI_H | 23 | #ifndef SCSI_TRANSPORT_ISCSI_H |
22 | #define SCSI_TRANSPORT_ISCSI_H | 24 | #define SCSI_TRANSPORT_ISCSI_H |
23 | 25 | ||
24 | #include <linux/config.h> | 26 | #include <scsi/iscsi_if.h> |
25 | #include <linux/in6.h> | ||
26 | #include <linux/in.h> | ||
27 | |||
28 | struct scsi_transport_template; | ||
29 | 27 | ||
30 | struct iscsi_class_session { | 28 | /** |
31 | uint8_t isid[6]; | 29 | * struct iscsi_transport - iSCSI Transport template |
32 | uint16_t tsih; | 30 | * |
33 | int header_digest; /* 1 CRC32, 0 None */ | 31 | * @name: transport name |
34 | int data_digest; /* 1 CRC32, 0 None */ | 32 | * @caps: iSCSI Data-Path capabilities |
35 | uint16_t tpgt; | 33 | * @create_session: create new iSCSI session object |
36 | union { | 34 | * @destroy_session: destroy existing iSCSI session object |
37 | struct in6_addr sin6_addr; | 35 | * @create_conn: create new iSCSI connection |
38 | struct in_addr sin_addr; | 36 | * @bind_conn: associate this connection with existing iSCSI session |
39 | } u; | 37 | * and specified transport descriptor |
40 | sa_family_t addr_type; /* must be AF_INET or AF_INET6 */ | 38 | * @destroy_conn: destroy inactive iSCSI connection |
41 | uint16_t port; /* must be in network byte order */ | 39 | * @set_param: set iSCSI Data-Path operational parameter |
42 | int initial_r2t; /* 1 Yes, 0 No */ | 40 | * @start_conn: set connection to be operational |
43 | int immediate_data; /* 1 Yes, 0 No */ | 41 | * @stop_conn: suspend/recover/terminate connection |
44 | uint32_t max_recv_data_segment_len; | 42 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. |
45 | uint32_t max_burst_len; | 43 | * |
46 | uint32_t first_burst_len; | 44 | * Template API provided by iSCSI Transport |
47 | uint16_t def_time2wait; | 45 | */ |
48 | uint16_t def_time2retain; | 46 | struct iscsi_transport { |
49 | uint16_t max_outstanding_r2t; | 47 | struct module *owner; |
50 | int data_pdu_in_order; /* 1 Yes, 0 No */ | 48 | char *name; |
51 | int data_sequence_in_order; /* 1 Yes, 0 No */ | 49 | unsigned int caps; |
52 | int erl; | 50 | struct scsi_host_template *host_template; |
51 | int hostdata_size; | ||
52 | int max_lun; | ||
53 | unsigned int max_conn; | ||
54 | unsigned int max_cmd_len; | ||
55 | iscsi_sessionh_t (*create_session) (uint32_t initial_cmdsn, | ||
56 | struct Scsi_Host *shost); | ||
57 | void (*destroy_session) (iscsi_sessionh_t session); | ||
58 | iscsi_connh_t (*create_conn) (iscsi_sessionh_t session, uint32_t cid); | ||
59 | int (*bind_conn) (iscsi_sessionh_t session, iscsi_connh_t conn, | ||
60 | uint32_t transport_fd, int is_leading); | ||
61 | int (*start_conn) (iscsi_connh_t conn); | ||
62 | void (*stop_conn) (iscsi_connh_t conn, int flag); | ||
63 | void (*destroy_conn) (iscsi_connh_t conn); | ||
64 | int (*set_param) (iscsi_connh_t conn, enum iscsi_param param, | ||
65 | uint32_t value); | ||
66 | int (*get_param) (iscsi_connh_t conn, enum iscsi_param param, | ||
67 | uint32_t *value); | ||
68 | int (*send_pdu) (iscsi_connh_t conn, struct iscsi_hdr *hdr, | ||
69 | char *data, uint32_t data_size); | ||
70 | void (*get_stats) (iscsi_connh_t conn, struct iscsi_stats *stats); | ||
53 | }; | 71 | }; |
54 | 72 | ||
55 | /* | 73 | /* |
56 | * accessor macros | 74 | * transport registration upcalls |
57 | */ | 75 | */ |
58 | #define iscsi_isid(x) \ | 76 | extern int iscsi_register_transport(struct iscsi_transport *tt); |
59 | (((struct iscsi_class_session *)&(x)->starget_data)->isid) | 77 | extern int iscsi_unregister_transport(struct iscsi_transport *tt); |
60 | #define iscsi_tsih(x) \ | ||
61 | (((struct iscsi_class_session *)&(x)->starget_data)->tsih) | ||
62 | #define iscsi_header_digest(x) \ | ||
63 | (((struct iscsi_class_session *)&(x)->starget_data)->header_digest) | ||
64 | #define iscsi_data_digest(x) \ | ||
65 | (((struct iscsi_class_session *)&(x)->starget_data)->data_digest) | ||
66 | #define iscsi_port(x) \ | ||
67 | (((struct iscsi_class_session *)&(x)->starget_data)->port) | ||
68 | #define iscsi_addr_type(x) \ | ||
69 | (((struct iscsi_class_session *)&(x)->starget_data)->addr_type) | ||
70 | #define iscsi_sin_addr(x) \ | ||
71 | (((struct iscsi_class_session *)&(x)->starget_data)->u.sin_addr) | ||
72 | #define iscsi_sin6_addr(x) \ | ||
73 | (((struct iscsi_class_session *)&(x)->starget_data)->u.sin6_addr) | ||
74 | #define iscsi_tpgt(x) \ | ||
75 | (((struct iscsi_class_session *)&(x)->starget_data)->tpgt) | ||
76 | #define iscsi_initial_r2t(x) \ | ||
77 | (((struct iscsi_class_session *)&(x)->starget_data)->initial_r2t) | ||
78 | #define iscsi_immediate_data(x) \ | ||
79 | (((struct iscsi_class_session *)&(x)->starget_data)->immediate_data) | ||
80 | #define iscsi_max_recv_data_segment_len(x) \ | ||
81 | (((struct iscsi_class_session *)&(x)->starget_data)->max_recv_data_segment_len) | ||
82 | #define iscsi_max_burst_len(x) \ | ||
83 | (((struct iscsi_class_session *)&(x)->starget_data)->max_burst_len) | ||
84 | #define iscsi_first_burst_len(x) \ | ||
85 | (((struct iscsi_class_session *)&(x)->starget_data)->first_burst_len) | ||
86 | #define iscsi_def_time2wait(x) \ | ||
87 | (((struct iscsi_class_session *)&(x)->starget_data)->def_time2wait) | ||
88 | #define iscsi_def_time2retain(x) \ | ||
89 | (((struct iscsi_class_session *)&(x)->starget_data)->def_time2retain) | ||
90 | #define iscsi_max_outstanding_r2t(x) \ | ||
91 | (((struct iscsi_class_session *)&(x)->starget_data)->max_outstanding_r2t) | ||
92 | #define iscsi_data_pdu_in_order(x) \ | ||
93 | (((struct iscsi_class_session *)&(x)->starget_data)->data_pdu_in_order) | ||
94 | #define iscsi_data_sequence_in_order(x) \ | ||
95 | (((struct iscsi_class_session *)&(x)->starget_data)->data_sequence_in_order) | ||
96 | #define iscsi_erl(x) \ | ||
97 | (((struct iscsi_class_session *)&(x)->starget_data)->erl) | ||
98 | 78 | ||
99 | /* | 79 | /* |
100 | * The functions by which the transport class and the driver communicate | 80 | * control plane upcalls |
101 | */ | 81 | */ |
102 | struct iscsi_function_template { | 82 | extern void iscsi_conn_error(iscsi_connh_t conn, enum iscsi_err error); |
103 | /* | 83 | extern int iscsi_recv_pdu(iscsi_connh_t conn, struct iscsi_hdr *hdr, |
104 | * target attrs | 84 | char *data, uint32_t data_size); |
105 | */ | ||
106 | void (*get_isid)(struct scsi_target *); | ||
107 | void (*get_tsih)(struct scsi_target *); | ||
108 | void (*get_header_digest)(struct scsi_target *); | ||
109 | void (*get_data_digest)(struct scsi_target *); | ||
110 | void (*get_port)(struct scsi_target *); | ||
111 | void (*get_tpgt)(struct scsi_target *); | ||
112 | /* | ||
113 | * In get_ip_address the lld must set the address and | ||
114 | * the address type | ||
115 | */ | ||
116 | void (*get_ip_address)(struct scsi_target *); | ||
117 | /* | ||
118 | * The lld should snprintf the name or alias to the buffer | ||
119 | */ | ||
120 | ssize_t (*get_target_name)(struct scsi_target *, char *, ssize_t); | ||
121 | ssize_t (*get_target_alias)(struct scsi_target *, char *, ssize_t); | ||
122 | void (*get_initial_r2t)(struct scsi_target *); | ||
123 | void (*get_immediate_data)(struct scsi_target *); | ||
124 | void (*get_max_recv_data_segment_len)(struct scsi_target *); | ||
125 | void (*get_max_burst_len)(struct scsi_target *); | ||
126 | void (*get_first_burst_len)(struct scsi_target *); | ||
127 | void (*get_def_time2wait)(struct scsi_target *); | ||
128 | void (*get_def_time2retain)(struct scsi_target *); | ||
129 | void (*get_max_outstanding_r2t)(struct scsi_target *); | ||
130 | void (*get_data_pdu_in_order)(struct scsi_target *); | ||
131 | void (*get_data_sequence_in_order)(struct scsi_target *); | ||
132 | void (*get_erl)(struct scsi_target *); | ||
133 | |||
134 | /* | ||
135 | * host atts | ||
136 | */ | ||
137 | |||
138 | /* | ||
139 | * The lld should snprintf the name or alias to the buffer | ||
140 | */ | ||
141 | ssize_t (*get_initiator_alias)(struct Scsi_Host *, char *, ssize_t); | ||
142 | ssize_t (*get_initiator_name)(struct Scsi_Host *, char *, ssize_t); | ||
143 | /* | ||
144 | * The driver sets these to tell the transport class it | ||
145 | * wants the attributes displayed in sysfs. If the show_ flag | ||
146 | * is not set, the attribute will be private to the transport | ||
147 | * class. We could probably just test if a get_ fn was set | ||
148 | * since we only use the values for sysfs but this is how | ||
149 | * fc does it too. | ||
150 | */ | ||
151 | unsigned long show_isid:1; | ||
152 | unsigned long show_tsih:1; | ||
153 | unsigned long show_header_digest:1; | ||
154 | unsigned long show_data_digest:1; | ||
155 | unsigned long show_port:1; | ||
156 | unsigned long show_tpgt:1; | ||
157 | unsigned long show_ip_address:1; | ||
158 | unsigned long show_target_name:1; | ||
159 | unsigned long show_target_alias:1; | ||
160 | unsigned long show_initial_r2t:1; | ||
161 | unsigned long show_immediate_data:1; | ||
162 | unsigned long show_max_recv_data_segment_len:1; | ||
163 | unsigned long show_max_burst_len:1; | ||
164 | unsigned long show_first_burst_len:1; | ||
165 | unsigned long show_def_time2wait:1; | ||
166 | unsigned long show_def_time2retain:1; | ||
167 | unsigned long show_max_outstanding_r2t:1; | ||
168 | unsigned long show_data_pdu_in_order:1; | ||
169 | unsigned long show_data_sequence_in_order:1; | ||
170 | unsigned long show_erl:1; | ||
171 | unsigned long show_initiator_name:1; | ||
172 | unsigned long show_initiator_alias:1; | ||
173 | }; | ||
174 | |||
175 | struct scsi_transport_template *iscsi_attach_transport(struct iscsi_function_template *); | ||
176 | void iscsi_release_transport(struct scsi_transport_template *); | ||
177 | 85 | ||
178 | #endif | 86 | #endif |