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.
26 #include <linux/in6.h>
28 #include <netinet/in.h>
31 #include "iscsi_proto.h"
33 #define ISCSI_NL_GRP_ISCSID 1
34 #define ISCSI_NL_GRP_UIP 2
36 #define UEVENT_BASE 10
37 #define KEVENT_BASE 100
38 #define ISCSI_ERR_BASE 1000
41 ISCSI_UEVENT_UNKNOWN
= 0,
44 ISCSI_UEVENT_CREATE_SESSION
= UEVENT_BASE
+ 1,
45 ISCSI_UEVENT_DESTROY_SESSION
= UEVENT_BASE
+ 2,
46 ISCSI_UEVENT_CREATE_CONN
= UEVENT_BASE
+ 3,
47 ISCSI_UEVENT_DESTROY_CONN
= UEVENT_BASE
+ 4,
48 ISCSI_UEVENT_BIND_CONN
= UEVENT_BASE
+ 5,
49 ISCSI_UEVENT_SET_PARAM
= UEVENT_BASE
+ 6,
50 ISCSI_UEVENT_START_CONN
= UEVENT_BASE
+ 7,
51 ISCSI_UEVENT_STOP_CONN
= UEVENT_BASE
+ 8,
52 ISCSI_UEVENT_SEND_PDU
= UEVENT_BASE
+ 9,
53 ISCSI_UEVENT_GET_STATS
= UEVENT_BASE
+ 10,
54 ISCSI_UEVENT_GET_PARAM
= UEVENT_BASE
+ 11,
56 ISCSI_UEVENT_TRANSPORT_EP_CONNECT
= UEVENT_BASE
+ 12,
57 ISCSI_UEVENT_TRANSPORT_EP_POLL
= UEVENT_BASE
+ 13,
58 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT
= UEVENT_BASE
+ 14,
60 ISCSI_UEVENT_TGT_DSCVR
= UEVENT_BASE
+ 15,
61 ISCSI_UEVENT_SET_HOST_PARAM
= UEVENT_BASE
+ 16,
62 ISCSI_UEVENT_UNBIND_SESSION
= UEVENT_BASE
+ 17,
63 ISCSI_UEVENT_CREATE_BOUND_SESSION
= UEVENT_BASE
+ 18,
64 ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST
= UEVENT_BASE
+ 19,
66 ISCSI_UEVENT_PATH_UPDATE
= UEVENT_BASE
+ 20,
68 ISCSI_UEVENT_MAX
= ISCSI_UEVENT_PATH_UPDATE
,
71 ISCSI_KEVENT_RECV_PDU
= KEVENT_BASE
+ 1,
72 ISCSI_KEVENT_CONN_ERROR
= KEVENT_BASE
+ 2,
73 ISCSI_KEVENT_IF_ERROR
= KEVENT_BASE
+ 3,
74 ISCSI_KEVENT_DESTROY_SESSION
= KEVENT_BASE
+ 4,
75 ISCSI_KEVENT_UNBIND_SESSION
= KEVENT_BASE
+ 5,
76 ISCSI_KEVENT_CREATE_SESSION
= KEVENT_BASE
+ 6,
78 ISCSI_KEVENT_PATH_REQ
= KEVENT_BASE
+ 7,
79 ISCSI_KEVENT_IF_DOWN
= KEVENT_BASE
+ 8,
81 ISCSI_KEVENT_MAX
= ISCSI_KEVENT_IF_DOWN
,
84 enum iscsi_tgt_dscvr
{
85 ISCSI_TGT_DSCVR_SEND_TARGETS
= 1,
86 ISCSI_TGT_DSCVR_ISNS
= 2,
87 ISCSI_TGT_DSCVR_SLP
= 3,
91 uint32_t type
; /* k/u events type */
92 uint32_t iferror
; /* carries interface or resource errors */
93 uint64_t transport_handle
;
97 struct msg_create_session
{
98 uint32_t initial_cmdsn
;
100 uint16_t queue_depth
;
102 struct msg_create_bound_session
{
104 uint32_t initial_cmdsn
;
106 uint16_t queue_depth
;
108 struct msg_destroy_session
{
111 struct msg_create_conn
{
115 struct msg_bind_conn
{
118 uint64_t transport_eph
;
121 struct msg_destroy_conn
{
125 struct msg_send_pdu
{
131 struct msg_set_param
{
134 uint32_t param
; /* enum iscsi_param */
137 struct msg_start_conn
{
141 struct msg_stop_conn
{
144 uint64_t conn_handle
;
147 struct msg_get_stats
{
151 struct msg_transport_connect
{
152 uint32_t non_blocking
;
154 struct msg_transport_connect_through_host
{
156 uint32_t non_blocking
;
157 } ep_connect_through_host
;
158 struct msg_transport_poll
{
162 struct msg_transport_disconnect
{
165 struct msg_tgt_dscvr
{
166 enum iscsi_tgt_dscvr type
;
169 * enable = 1 to establish a new connection
170 * with the server. enable = 0 to disconnect
171 * from the server. Used primarily to switch
172 * from one iSNS server to another.
176 struct msg_set_host_param
{
178 uint32_t param
; /* enum iscsi_host_param */
181 struct msg_set_path
{
186 /* messages k -> u */
188 struct msg_create_session_ret
{
192 struct msg_create_conn_ret
{
196 struct msg_unbind_session
{
200 struct msg_recv_req
{
203 uint64_t recv_handle
;
205 struct msg_conn_error
{
208 uint32_t error
; /* enum iscsi_err */
210 struct msg_session_destroyed
{
214 struct msg_transport_connect_ret
{
217 struct msg_req_path
{
220 struct msg_notify_if_down
{
224 } __attribute__ ((aligned (sizeof(uint64_t))));
227 * To keep the struct iscsi_uevent size the same for userspace code
228 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
229 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
230 * struct iscsi_uevent in the NETLINK_ISCSI message.
235 uint8_t mac_addr_old
[6];
236 uint32_t ip_addr_len
; /* 4 or 16 */
238 struct in_addr v4_addr
;
239 struct in6_addr v6_addr
;
242 struct in_addr v4_addr
;
243 struct in6_addr v6_addr
;
247 } __attribute__ ((aligned (sizeof(uint64_t))));
255 ISCSI_ERR_DATASN
= ISCSI_ERR_BASE
+ 1,
256 ISCSI_ERR_DATA_OFFSET
= ISCSI_ERR_BASE
+ 2,
257 ISCSI_ERR_MAX_CMDSN
= ISCSI_ERR_BASE
+ 3,
258 ISCSI_ERR_EXP_CMDSN
= ISCSI_ERR_BASE
+ 4,
259 ISCSI_ERR_BAD_OPCODE
= ISCSI_ERR_BASE
+ 5,
260 ISCSI_ERR_DATALEN
= ISCSI_ERR_BASE
+ 6,
261 ISCSI_ERR_AHSLEN
= ISCSI_ERR_BASE
+ 7,
262 ISCSI_ERR_PROTO
= ISCSI_ERR_BASE
+ 8,
263 ISCSI_ERR_LUN
= ISCSI_ERR_BASE
+ 9,
264 ISCSI_ERR_BAD_ITT
= ISCSI_ERR_BASE
+ 10,
265 ISCSI_ERR_CONN_FAILED
= ISCSI_ERR_BASE
+ 11,
266 ISCSI_ERR_R2TSN
= ISCSI_ERR_BASE
+ 12,
267 ISCSI_ERR_SESSION_FAILED
= ISCSI_ERR_BASE
+ 13,
268 ISCSI_ERR_HDR_DGST
= ISCSI_ERR_BASE
+ 14,
269 ISCSI_ERR_DATA_DGST
= ISCSI_ERR_BASE
+ 15,
270 ISCSI_ERR_PARAM_NOT_FOUND
= ISCSI_ERR_BASE
+ 16,
271 ISCSI_ERR_NO_SCSI_CMD
= ISCSI_ERR_BASE
+ 17,
272 ISCSI_ERR_INVALID_HOST
= ISCSI_ERR_BASE
+ 18,
273 ISCSI_ERR_XMIT_FAILED
= ISCSI_ERR_BASE
+ 19,
274 ISCSI_ERR_TCP_CONN_CLOSE
= ISCSI_ERR_BASE
+ 20,
278 * iSCSI Parameters (RFC3720)
281 /* passed in using netlink set param */
282 ISCSI_PARAM_MAX_RECV_DLENGTH
,
283 ISCSI_PARAM_MAX_XMIT_DLENGTH
,
284 ISCSI_PARAM_HDRDGST_EN
,
285 ISCSI_PARAM_DATADGST_EN
,
286 ISCSI_PARAM_INITIAL_R2T_EN
,
288 ISCSI_PARAM_IMM_DATA_EN
,
289 ISCSI_PARAM_FIRST_BURST
,
290 ISCSI_PARAM_MAX_BURST
,
291 ISCSI_PARAM_PDU_INORDER_EN
,
292 ISCSI_PARAM_DATASEQ_INORDER_EN
,
294 ISCSI_PARAM_IFMARKER_EN
,
295 ISCSI_PARAM_OFMARKER_EN
,
296 ISCSI_PARAM_EXP_STATSN
,
297 ISCSI_PARAM_TARGET_NAME
,
299 ISCSI_PARAM_PERSISTENT_ADDRESS
,
300 ISCSI_PARAM_PERSISTENT_PORT
,
301 ISCSI_PARAM_SESS_RECOVERY_TMO
,
303 /* pased in through bind conn using transport_fd */
304 ISCSI_PARAM_CONN_PORT
,
305 ISCSI_PARAM_CONN_ADDRESS
,
307 ISCSI_PARAM_USERNAME
,
308 ISCSI_PARAM_USERNAME_IN
,
309 ISCSI_PARAM_PASSWORD
,
310 ISCSI_PARAM_PASSWORD_IN
,
312 ISCSI_PARAM_FAST_ABORT
,
313 ISCSI_PARAM_ABORT_TMO
,
314 ISCSI_PARAM_LU_RESET_TMO
,
315 ISCSI_PARAM_HOST_RESET_TMO
,
317 ISCSI_PARAM_PING_TMO
,
318 ISCSI_PARAM_RECV_TMO
,
320 ISCSI_PARAM_IFACE_NAME
,
322 ISCSI_PARAM_INITIATOR_NAME
,
324 ISCSI_PARAM_TGT_RESET_TMO
,
325 /* must always be last */
329 #define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
330 #define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
331 #define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
332 #define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
333 #define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
334 #define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
335 #define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
336 #define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
337 #define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
338 #define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
339 #define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
340 #define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
341 #define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
342 #define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
343 #define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
344 #define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
345 #define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
346 #define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
347 #define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
348 #define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
349 #define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
350 #define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
351 #define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
352 #define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
353 #define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
354 #define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
355 #define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
356 #define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
357 #define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
358 #define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
359 #define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
360 #define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
361 #define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
362 #define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
363 #define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
364 #define ISCSI_TGT_RESET_TMO (1ULL << ISCSI_PARAM_TGT_RESET_TMO)
366 /* iSCSI HBA params */
367 enum iscsi_host_param
{
368 ISCSI_HOST_PARAM_HWADDRESS
,
369 ISCSI_HOST_PARAM_INITIATOR_NAME
,
370 ISCSI_HOST_PARAM_NETDEV_NAME
,
371 ISCSI_HOST_PARAM_IPADDRESS
,
372 ISCSI_HOST_PARAM_MAX
,
375 #define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
376 #define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
377 #define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
378 #define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
380 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
381 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
384 * These flags presents iSCSI Data-Path capabilities.
386 #define CAP_RECOVERY_L0 0x1
387 #define CAP_RECOVERY_L1 0x2
388 #define CAP_RECOVERY_L2 0x4
389 #define CAP_MULTI_R2T 0x8
390 #define CAP_HDRDGST 0x10
391 #define CAP_DATADGST 0x20
392 #define CAP_MULTI_CONN 0x40
393 #define CAP_TEXT_NEGO 0x80 /* support for text requests */
394 #define CAP_MARKERS 0x100
395 #define CAP_FW_DB 0x200
396 #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
397 #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
398 #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
399 #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
403 * These flags describes reason of stop_conn() call
405 #define STOP_CONN_TERM 0x1
406 #define STOP_CONN_SUSPEND 0x2
407 #define STOP_CONN_RECOVER 0x3
409 #define ISCSI_STATS_CUSTOM_MAX 32
410 #define ISCSI_STATS_CUSTOM_DESC_MAX 64
411 struct iscsi_stats_custom
{
412 char desc
[ISCSI_STATS_CUSTOM_DESC_MAX
];
417 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
419 * Note: this structure contains counters collected on per-connection basis.
423 uint64_t txdata_octets
;
424 uint64_t rxdata_octets
;
428 uint32_t scsicmd_pdus
;
429 uint32_t tmfcmd_pdus
;
432 uint32_t dataout_pdus
;
433 uint32_t logout_pdus
;
438 uint32_t scsirsp_pdus
;
439 uint32_t tmfrsp_pdus
;
440 uint32_t textrsp_pdus
;
441 uint32_t datain_pdus
;
442 uint32_t logoutrsp_pdus
;
449 uint32_t timeout_err
;
452 * iSCSI Custom Statistics support, i.e. Transport could
453 * extend existing MIB statistics with its own specific statistics
454 * up to ISCSI_STATS_CUSTOM_MAX
456 uint32_t custom_length
;
457 struct iscsi_stats_custom custom
[0]
458 __attribute__ ((aligned (sizeof(uint64_t))));