2 * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
4 * Copyright (C) 2005 Dmitry Yusupov
5 * Copyright (C) 2005 Alex Aizman
6 * maintained by open-iscsi@googlegroups.com
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.
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.
18 * See the file COPYING included with this distribution for more details.
24 #include <scsi/iscsi_proto.h>
26 #define UEVENT_BASE 10
27 #define KEVENT_BASE 100
28 #define ISCSI_ERR_BASE 1000
31 ISCSI_UEVENT_UNKNOWN = 0,
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,
46 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
47 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
51 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
52 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
53 ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
56 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
57 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
58 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
59 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
60 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
61 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
64 enum iscsi_tgt_dscvr {
65 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
66 ISCSI_TGT_DSCVR_ISNS = 2,
67 ISCSI_TGT_DSCVR_SLP = 3,
71 uint32_t type; /* k/u events type */
72 uint32_t iferror; /* carries interface or resource errors */
73 uint64_t transport_handle;
77 struct msg_create_session {
78 uint32_t initial_cmdsn;
82 struct msg_create_bound_session {
84 uint32_t initial_cmdsn;
88 struct msg_destroy_session {
91 struct msg_create_conn {
95 struct msg_bind_conn {
98 uint64_t transport_eph;
101 struct msg_destroy_conn {
105 struct msg_send_pdu {
111 struct msg_set_param {
114 uint32_t param; /* enum iscsi_param */
117 struct msg_start_conn {
121 struct msg_stop_conn {
124 uint64_t conn_handle;
127 struct msg_get_stats {
131 struct msg_transport_connect {
132 uint32_t non_blocking;
134 struct msg_transport_poll {
138 struct msg_transport_disconnect {
141 struct msg_tgt_dscvr {
142 enum iscsi_tgt_dscvr type;
145 * enable = 1 to establish a new connection
146 * with the server. enable = 0 to disconnect
147 * from the server. Used primarily to switch
148 * from one iSNS server to another.
152 struct msg_set_host_param {
154 uint32_t param; /* enum iscsi_host_param */
159 /* messages k -> u */
161 struct msg_create_session_ret {
165 struct msg_create_conn_ret {
169 struct msg_unbind_session {
173 struct msg_recv_req {
176 uint64_t recv_handle;
178 struct msg_conn_error {
181 uint32_t error; /* enum iscsi_err */
183 struct msg_session_destroyed {
187 struct msg_transport_connect_ret {
191 } __attribute__ ((aligned (sizeof(uint64_t))));
199 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
200 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
201 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
202 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
203 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
204 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
205 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
206 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
207 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
208 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
209 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
210 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
211 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
212 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
213 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
214 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
215 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
219 * iSCSI Parameters (RFC3720)
222 /* passed in using netlink set param */
223 ISCSI_PARAM_MAX_RECV_DLENGTH,
224 ISCSI_PARAM_MAX_XMIT_DLENGTH,
225 ISCSI_PARAM_HDRDGST_EN,
226 ISCSI_PARAM_DATADGST_EN,
227 ISCSI_PARAM_INITIAL_R2T_EN,
229 ISCSI_PARAM_IMM_DATA_EN,
230 ISCSI_PARAM_FIRST_BURST,
231 ISCSI_PARAM_MAX_BURST,
232 ISCSI_PARAM_PDU_INORDER_EN,
233 ISCSI_PARAM_DATASEQ_INORDER_EN,
235 ISCSI_PARAM_IFMARKER_EN,
236 ISCSI_PARAM_OFMARKER_EN,
237 ISCSI_PARAM_EXP_STATSN,
238 ISCSI_PARAM_TARGET_NAME,
240 ISCSI_PARAM_PERSISTENT_ADDRESS,
241 ISCSI_PARAM_PERSISTENT_PORT,
242 ISCSI_PARAM_SESS_RECOVERY_TMO,
244 /* pased in through bind conn using transport_fd */
245 ISCSI_PARAM_CONN_PORT,
246 ISCSI_PARAM_CONN_ADDRESS,
248 ISCSI_PARAM_USERNAME,
249 ISCSI_PARAM_USERNAME_IN,
250 ISCSI_PARAM_PASSWORD,
251 ISCSI_PARAM_PASSWORD_IN,
253 ISCSI_PARAM_FAST_ABORT,
254 ISCSI_PARAM_ABORT_TMO,
255 ISCSI_PARAM_LU_RESET_TMO,
256 ISCSI_PARAM_HOST_RESET_TMO,
258 ISCSI_PARAM_PING_TMO,
259 ISCSI_PARAM_RECV_TMO,
261 ISCSI_PARAM_IFACE_NAME,
263 ISCSI_PARAM_INITIATOR_NAME,
264 /* must always be last */
268 #define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
269 #define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
270 #define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
271 #define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
272 #define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
273 #define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
274 #define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
275 #define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
276 #define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
277 #define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
278 #define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
279 #define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
280 #define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
281 #define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
282 #define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
283 #define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
284 #define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
285 #define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
286 #define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
287 #define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
288 #define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
289 #define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
290 #define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
291 #define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
292 #define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
293 #define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
294 #define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
295 #define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
296 #define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
297 #define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
298 #define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
299 #define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
300 #define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
301 #define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
302 #define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
304 /* iSCSI HBA params */
305 enum iscsi_host_param {
306 ISCSI_HOST_PARAM_HWADDRESS,
307 ISCSI_HOST_PARAM_INITIATOR_NAME,
308 ISCSI_HOST_PARAM_NETDEV_NAME,
309 ISCSI_HOST_PARAM_IPADDRESS,
310 ISCSI_HOST_PARAM_MAX,
313 #define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
314 #define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
315 #define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
316 #define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
318 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
319 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
322 * These flags presents iSCSI Data-Path capabilities.
324 #define CAP_RECOVERY_L0 0x1
325 #define CAP_RECOVERY_L1 0x2
326 #define CAP_RECOVERY_L2 0x4
327 #define CAP_MULTI_R2T 0x8
328 #define CAP_HDRDGST 0x10
329 #define CAP_DATADGST 0x20
330 #define CAP_MULTI_CONN 0x40
331 #define CAP_TEXT_NEGO 0x80
332 #define CAP_MARKERS 0x100
333 #define CAP_FW_DB 0x200
334 #define CAP_SENDTARGETS_OFFLOAD 0x400
335 #define CAP_DATA_PATH_OFFLOAD 0x800
338 * These flags describes reason of stop_conn() call
340 #define STOP_CONN_TERM 0x1
341 #define STOP_CONN_SUSPEND 0x2
342 #define STOP_CONN_RECOVER 0x3
344 #define ISCSI_STATS_CUSTOM_MAX 32
345 #define ISCSI_STATS_CUSTOM_DESC_MAX 64
346 struct iscsi_stats_custom {
347 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
352 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
354 * Note: this structure contains counters collected on per-connection basis.
358 uint64_t txdata_octets;
359 uint64_t rxdata_octets;
363 uint32_t scsicmd_pdus;
364 uint32_t tmfcmd_pdus;
367 uint32_t dataout_pdus;
368 uint32_t logout_pdus;
373 uint32_t scsirsp_pdus;
374 uint32_t tmfrsp_pdus;
375 uint32_t textrsp_pdus;
376 uint32_t datain_pdus;
377 uint32_t logoutrsp_pdus;
384 uint32_t timeout_err;
387 * iSCSI Custom Statistics support, i.e. Transport could
388 * extend existing MIB statistics with its own specific statistics
389 * up to ISCSI_STATS_CUSTOM_MAX
391 uint32_t custom_length;
392 struct iscsi_stats_custom custom[0]
393 __attribute__ ((aligned (sizeof(uint64_t))));