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,
47 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
48 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
49 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
53 uint32_t type; /* k/u events type */
54 uint32_t iferror; /* carries interface or resource errors */
55 uint64_t transport_handle;
59 struct msg_create_session {
60 uint32_t initial_cmdsn;
62 struct msg_destroy_session {
65 struct msg_create_conn {
69 struct msg_bind_conn {
72 uint32_t transport_fd;
75 struct msg_destroy_conn {
85 struct msg_set_param {
88 uint32_t param; /* enum iscsi_param */
91 struct msg_start_conn {
95 struct msg_stop_conn {
101 struct msg_get_stats {
107 /* messages k -> u */
109 struct msg_create_session_ret {
113 struct msg_create_conn_ret {
117 struct msg_recv_req {
120 uint64_t recv_handle;
122 struct msg_conn_error {
125 uint32_t error; /* enum iscsi_err */
128 } __attribute__ ((aligned (sizeof(uint64_t))));
136 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
137 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
138 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
139 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
140 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
141 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
142 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
143 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
144 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
145 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
146 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
147 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
148 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
149 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
150 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
151 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16
155 * iSCSI Parameters (RFC3720)
158 ISCSI_PARAM_MAX_RECV_DLENGTH = 0,
159 ISCSI_PARAM_MAX_XMIT_DLENGTH = 1,
160 ISCSI_PARAM_HDRDGST_EN = 2,
161 ISCSI_PARAM_DATADGST_EN = 3,
162 ISCSI_PARAM_INITIAL_R2T_EN = 4,
163 ISCSI_PARAM_MAX_R2T = 5,
164 ISCSI_PARAM_IMM_DATA_EN = 6,
165 ISCSI_PARAM_FIRST_BURST = 7,
166 ISCSI_PARAM_MAX_BURST = 8,
167 ISCSI_PARAM_PDU_INORDER_EN = 9,
168 ISCSI_PARAM_DATASEQ_INORDER_EN = 10,
169 ISCSI_PARAM_ERL = 11,
170 ISCSI_PARAM_IFMARKER_EN = 12,
171 ISCSI_PARAM_OFMARKER_EN = 13,
173 #define ISCSI_PARAM_MAX 14
175 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
176 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
177 #define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))
180 * iscsi_hostdata - get LLD hostdata from scsi_host
181 * @_hostdata: pointer to scsi host's hostdata
183 #define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long))
186 * These flags presents iSCSI Data-Path capabilities.
188 #define CAP_RECOVERY_L0 0x1
189 #define CAP_RECOVERY_L1 0x2
190 #define CAP_RECOVERY_L2 0x4
191 #define CAP_MULTI_R2T 0x8
192 #define CAP_HDRDGST 0x10
193 #define CAP_DATADGST 0x20
194 #define CAP_MULTI_CONN 0x40
195 #define CAP_TEXT_NEGO 0x80
196 #define CAP_MARKERS 0x100
199 * These flags describes reason of stop_conn() call
201 #define STOP_CONN_TERM 0x1
202 #define STOP_CONN_SUSPEND 0x2
203 #define STOP_CONN_RECOVER 0x3
205 #define ISCSI_STATS_CUSTOM_MAX 32
206 #define ISCSI_STATS_CUSTOM_DESC_MAX 64
207 struct iscsi_stats_custom {
208 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
213 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
215 * Note: this structure contains counters collected on per-connection basis.
219 uint64_t txdata_octets;
220 uint64_t rxdata_octets;
224 uint32_t scsicmd_pdus;
225 uint32_t tmfcmd_pdus;
228 uint32_t dataout_pdus;
229 uint32_t logout_pdus;
234 uint32_t scsirsp_pdus;
235 uint32_t tmfrsp_pdus;
236 uint32_t textrsp_pdus;
237 uint32_t datain_pdus;
238 uint32_t logoutrsp_pdus;
245 uint32_t timeout_err;
248 * iSCSI Custom Statistics support, i.e. Transport could
249 * extend existing MIB statistics with its own specific statistics
250 * up to ISCSI_STATS_CUSTOM_MAX
252 uint32_t custom_length;
253 struct iscsi_stats_custom custom[0]
254 __attribute__ ((aligned (sizeof(uint64_t))));