Loading...
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#include <linux/in.h>
26#include <linux/in6.h>
27
28#define ISCSI_NL_GRP_ISCSID 1
29#define ISCSI_NL_GRP_UIP 2
30
31#define UEVENT_BASE 10
32#define KEVENT_BASE 100
33#define ISCSI_ERR_BASE 1000
34
35enum iscsi_uevent_e {
36 ISCSI_UEVENT_UNKNOWN = 0,
37
38 /* down events */
39 ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1,
40 ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2,
41 ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3,
42 ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4,
43 ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5,
44 ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6,
45 ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7,
46 ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8,
47 ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9,
48 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
49 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
50
51 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
52 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
53 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
54
55 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
56 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
57 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
58 ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
59 ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19,
60
61 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20,
62
63 /* up events */
64 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
65 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
66 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
67 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
68 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
69 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
70
71 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
72 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
73};
74
75enum iscsi_tgt_dscvr {
76 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
77 ISCSI_TGT_DSCVR_ISNS = 2,
78 ISCSI_TGT_DSCVR_SLP = 3,
79};
80
81struct iscsi_uevent {
82 uint32_t type; /* k/u events type */
83 uint32_t iferror; /* carries interface or resource errors */
84 uint64_t transport_handle;
85
86 union {
87 /* messages u -> k */
88 struct msg_create_session {
89 uint32_t initial_cmdsn;
90 uint16_t cmds_max;
91 uint16_t queue_depth;
92 } c_session;
93 struct msg_create_bound_session {
94 uint64_t ep_handle;
95 uint32_t initial_cmdsn;
96 uint16_t cmds_max;
97 uint16_t queue_depth;
98 } c_bound_session;
99 struct msg_destroy_session {
100 uint32_t sid;
101 } d_session;
102 struct msg_create_conn {
103 uint32_t sid;
104 uint32_t cid;
105 } c_conn;
106 struct msg_bind_conn {
107 uint32_t sid;
108 uint32_t cid;
109 uint64_t transport_eph;
110 uint32_t is_leading;
111 } b_conn;
112 struct msg_destroy_conn {
113 uint32_t sid;
114 uint32_t cid;
115 } d_conn;
116 struct msg_send_pdu {
117 uint32_t sid;
118 uint32_t cid;
119 uint32_t hdr_size;
120 uint32_t data_size;
121 } send_pdu;
122 struct msg_set_param {
123 uint32_t sid;
124 uint32_t cid;
125 uint32_t param; /* enum iscsi_param */
126 uint32_t len;
127 } set_param;
128 struct msg_start_conn {
129 uint32_t sid;
130 uint32_t cid;
131 } start_conn;
132 struct msg_stop_conn {
133 uint32_t sid;
134 uint32_t cid;
135 uint64_t conn_handle;
136 uint32_t flag;
137 } stop_conn;
138 struct msg_get_stats {
139 uint32_t sid;
140 uint32_t cid;
141 } get_stats;
142 struct msg_transport_connect {
143 uint32_t non_blocking;
144 } ep_connect;
145 struct msg_transport_connect_through_host {
146 uint32_t host_no;
147 uint32_t non_blocking;
148 } ep_connect_through_host;
149 struct msg_transport_poll {
150 uint64_t ep_handle;
151 uint32_t timeout_ms;
152 } ep_poll;
153 struct msg_transport_disconnect {
154 uint64_t ep_handle;
155 } ep_disconnect;
156 struct msg_tgt_dscvr {
157 enum iscsi_tgt_dscvr type;
158 uint32_t host_no;
159 /*
160 * enable = 1 to establish a new connection
161 * with the server. enable = 0 to disconnect
162 * from the server. Used primarily to switch
163 * from one iSNS server to another.
164 */
165 uint32_t enable;
166 } tgt_dscvr;
167 struct msg_set_host_param {
168 uint32_t host_no;
169 uint32_t param; /* enum iscsi_host_param */
170 uint32_t len;
171 } set_host_param;
172 struct msg_set_path {
173 uint32_t host_no;
174 } set_path;
175 } u;
176 union {
177 /* messages k -> u */
178 int retcode;
179 struct msg_create_session_ret {
180 uint32_t sid;
181 uint32_t host_no;
182 } c_session_ret;
183 struct msg_create_conn_ret {
184 uint32_t sid;
185 uint32_t cid;
186 } c_conn_ret;
187 struct msg_unbind_session {
188 uint32_t sid;
189 uint32_t host_no;
190 } unbind_session;
191 struct msg_recv_req {
192 uint32_t sid;
193 uint32_t cid;
194 uint64_t recv_handle;
195 } recv_req;
196 struct msg_conn_error {
197 uint32_t sid;
198 uint32_t cid;
199 uint32_t error; /* enum iscsi_err */
200 } connerror;
201 struct msg_session_destroyed {
202 uint32_t host_no;
203 uint32_t sid;
204 } d_session;
205 struct msg_transport_connect_ret {
206 uint64_t handle;
207 } ep_connect_ret;
208 struct msg_req_path {
209 uint32_t host_no;
210 } req_path;
211 struct msg_notify_if_down {
212 uint32_t host_no;
213 } notify_if_down;
214 } r;
215} __attribute__ ((aligned (sizeof(uint64_t))));
216
217/*
218 * To keep the struct iscsi_uevent size the same for userspace code
219 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
220 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
221 * struct iscsi_uevent in the NETLINK_ISCSI message.
222 */
223struct iscsi_path {
224 uint64_t handle;
225 uint8_t mac_addr[6];
226 uint8_t mac_addr_old[6];
227 uint32_t ip_addr_len; /* 4 or 16 */
228 union {
229 struct in_addr v4_addr;
230 struct in6_addr v6_addr;
231 } src;
232 union {
233 struct in_addr v4_addr;
234 struct in6_addr v6_addr;
235 } dst;
236 uint16_t vlan_id;
237 uint16_t pmtu;
238} __attribute__ ((aligned (sizeof(uint64_t))));
239
240/*
241 * Common error codes
242 */
243enum iscsi_err {
244 ISCSI_OK = 0,
245
246 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
247 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
248 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
249 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
250 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
251 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
252 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
253 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
254 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
255 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
256 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
257 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
258 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
259 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
260 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
261 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
262 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
263 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
264 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
265 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
266 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
267};
268
269/*
270 * iSCSI Parameters (RFC3720)
271 */
272enum iscsi_param {
273 /* passed in using netlink set param */
274 ISCSI_PARAM_MAX_RECV_DLENGTH,
275 ISCSI_PARAM_MAX_XMIT_DLENGTH,
276 ISCSI_PARAM_HDRDGST_EN,
277 ISCSI_PARAM_DATADGST_EN,
278 ISCSI_PARAM_INITIAL_R2T_EN,
279 ISCSI_PARAM_MAX_R2T,
280 ISCSI_PARAM_IMM_DATA_EN,
281 ISCSI_PARAM_FIRST_BURST,
282 ISCSI_PARAM_MAX_BURST,
283 ISCSI_PARAM_PDU_INORDER_EN,
284 ISCSI_PARAM_DATASEQ_INORDER_EN,
285 ISCSI_PARAM_ERL,
286 ISCSI_PARAM_IFMARKER_EN,
287 ISCSI_PARAM_OFMARKER_EN,
288 ISCSI_PARAM_EXP_STATSN,
289 ISCSI_PARAM_TARGET_NAME,
290 ISCSI_PARAM_TPGT,
291 ISCSI_PARAM_PERSISTENT_ADDRESS,
292 ISCSI_PARAM_PERSISTENT_PORT,
293 ISCSI_PARAM_SESS_RECOVERY_TMO,
294
295 /* passed in through bind conn using transport_fd */
296 ISCSI_PARAM_CONN_PORT,
297 ISCSI_PARAM_CONN_ADDRESS,
298
299 ISCSI_PARAM_USERNAME,
300 ISCSI_PARAM_USERNAME_IN,
301 ISCSI_PARAM_PASSWORD,
302 ISCSI_PARAM_PASSWORD_IN,
303
304 ISCSI_PARAM_FAST_ABORT,
305 ISCSI_PARAM_ABORT_TMO,
306 ISCSI_PARAM_LU_RESET_TMO,
307 ISCSI_PARAM_HOST_RESET_TMO,
308
309 ISCSI_PARAM_PING_TMO,
310 ISCSI_PARAM_RECV_TMO,
311
312 ISCSI_PARAM_IFACE_NAME,
313 ISCSI_PARAM_ISID,
314 ISCSI_PARAM_INITIATOR_NAME,
315
316 ISCSI_PARAM_TGT_RESET_TMO,
317 ISCSI_PARAM_TARGET_ALIAS,
318 /* must always be last */
319 ISCSI_PARAM_MAX,
320};
321
322#define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
323#define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
324#define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
325#define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
326#define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
327#define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
328#define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
329#define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
330#define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
331#define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
332#define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
333#define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
334#define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
335#define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
336#define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
337#define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
338#define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
339#define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
340#define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
341#define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
342#define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
343#define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
344#define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
345#define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
346#define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
347#define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
348#define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
349#define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
350#define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
351#define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
352#define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
353#define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
354#define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
355#define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
356#define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
357#define ISCSI_TGT_RESET_TMO (1ULL << ISCSI_PARAM_TGT_RESET_TMO)
358#define ISCSI_TARGET_ALIAS (1ULL << ISCSI_PARAM_TARGET_ALIAS)
359
360/* iSCSI HBA params */
361enum iscsi_host_param {
362 ISCSI_HOST_PARAM_HWADDRESS,
363 ISCSI_HOST_PARAM_INITIATOR_NAME,
364 ISCSI_HOST_PARAM_NETDEV_NAME,
365 ISCSI_HOST_PARAM_IPADDRESS,
366 ISCSI_HOST_PARAM_MAX,
367};
368
369#define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
370#define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
371#define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
372#define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
373
374#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
375#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
376
377/*
378 * These flags presents iSCSI Data-Path capabilities.
379 */
380#define CAP_RECOVERY_L0 0x1
381#define CAP_RECOVERY_L1 0x2
382#define CAP_RECOVERY_L2 0x4
383#define CAP_MULTI_R2T 0x8
384#define CAP_HDRDGST 0x10
385#define CAP_DATADGST 0x20
386#define CAP_MULTI_CONN 0x40
387#define CAP_TEXT_NEGO 0x80
388#define CAP_MARKERS 0x100
389#define CAP_FW_DB 0x200
390#define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
391#define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
392#define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
393#define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
394 and verification */
395
396/*
397 * These flags describes reason of stop_conn() call
398 */
399#define STOP_CONN_TERM 0x1
400#define STOP_CONN_SUSPEND 0x2
401#define STOP_CONN_RECOVER 0x3
402
403#define ISCSI_STATS_CUSTOM_MAX 32
404#define ISCSI_STATS_CUSTOM_DESC_MAX 64
405struct iscsi_stats_custom {
406 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
407 uint64_t value;
408};
409
410/*
411 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
412 *
413 * Note: this structure contains counters collected on per-connection basis.
414 */
415struct iscsi_stats {
416 /* octets */
417 uint64_t txdata_octets;
418 uint64_t rxdata_octets;
419
420 /* xmit pdus */
421 uint32_t noptx_pdus;
422 uint32_t scsicmd_pdus;
423 uint32_t tmfcmd_pdus;
424 uint32_t login_pdus;
425 uint32_t text_pdus;
426 uint32_t dataout_pdus;
427 uint32_t logout_pdus;
428 uint32_t snack_pdus;
429
430 /* recv pdus */
431 uint32_t noprx_pdus;
432 uint32_t scsirsp_pdus;
433 uint32_t tmfrsp_pdus;
434 uint32_t textrsp_pdus;
435 uint32_t datain_pdus;
436 uint32_t logoutrsp_pdus;
437 uint32_t r2t_pdus;
438 uint32_t async_pdus;
439 uint32_t rjt_pdus;
440
441 /* errors */
442 uint32_t digest_err;
443 uint32_t timeout_err;
444
445 /*
446 * iSCSI Custom Statistics support, i.e. Transport could
447 * extend existing MIB statistics with its own specific statistics
448 * up to ISCSI_STATS_CUSTOM_MAX
449 */
450 uint32_t custom_length;
451 struct iscsi_stats_custom custom[0]
452 __attribute__ ((aligned (sizeof(uint64_t))));
453};
454
455#endif
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#include <linux/in.h>
26#include <linux/in6.h>
27
28#define ISCSI_NL_GRP_ISCSID 1
29#define ISCSI_NL_GRP_UIP 2
30
31#define UEVENT_BASE 10
32#define KEVENT_BASE 100
33#define ISCSI_ERR_BASE 1000
34
35enum iscsi_uevent_e {
36 ISCSI_UEVENT_UNKNOWN = 0,
37
38 /* down events */
39 ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1,
40 ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2,
41 ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3,
42 ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4,
43 ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5,
44 ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6,
45 ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7,
46 ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8,
47 ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9,
48 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
49 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
50
51 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
52 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
53 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
54
55 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
56 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
57 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
58 ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
59 ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19,
60
61 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20,
62 ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21,
63 ISCSI_UEVENT_PING = UEVENT_BASE + 22,
64 ISCSI_UEVENT_GET_CHAP = UEVENT_BASE + 23,
65 ISCSI_UEVENT_DELETE_CHAP = UEVENT_BASE + 24,
66
67 /* up events */
68 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
69 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
70 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
71 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
72 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
73 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
74
75 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
76 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
77 ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
78 ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
79 ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11,
80};
81
82enum iscsi_tgt_dscvr {
83 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
84 ISCSI_TGT_DSCVR_ISNS = 2,
85 ISCSI_TGT_DSCVR_SLP = 3,
86};
87
88enum iscsi_host_event_code {
89 ISCSI_EVENT_LINKUP = 1,
90 ISCSI_EVENT_LINKDOWN,
91 /* must always be last */
92 ISCSI_EVENT_MAX,
93};
94
95struct iscsi_uevent {
96 uint32_t type; /* k/u events type */
97 uint32_t iferror; /* carries interface or resource errors */
98 uint64_t transport_handle;
99
100 union {
101 /* messages u -> k */
102 struct msg_create_session {
103 uint32_t initial_cmdsn;
104 uint16_t cmds_max;
105 uint16_t queue_depth;
106 } c_session;
107 struct msg_create_bound_session {
108 uint64_t ep_handle;
109 uint32_t initial_cmdsn;
110 uint16_t cmds_max;
111 uint16_t queue_depth;
112 } c_bound_session;
113 struct msg_destroy_session {
114 uint32_t sid;
115 } d_session;
116 struct msg_create_conn {
117 uint32_t sid;
118 uint32_t cid;
119 } c_conn;
120 struct msg_bind_conn {
121 uint32_t sid;
122 uint32_t cid;
123 uint64_t transport_eph;
124 uint32_t is_leading;
125 } b_conn;
126 struct msg_destroy_conn {
127 uint32_t sid;
128 uint32_t cid;
129 } d_conn;
130 struct msg_send_pdu {
131 uint32_t sid;
132 uint32_t cid;
133 uint32_t hdr_size;
134 uint32_t data_size;
135 } send_pdu;
136 struct msg_set_param {
137 uint32_t sid;
138 uint32_t cid;
139 uint32_t param; /* enum iscsi_param */
140 uint32_t len;
141 } set_param;
142 struct msg_start_conn {
143 uint32_t sid;
144 uint32_t cid;
145 } start_conn;
146 struct msg_stop_conn {
147 uint32_t sid;
148 uint32_t cid;
149 uint64_t conn_handle;
150 uint32_t flag;
151 } stop_conn;
152 struct msg_get_stats {
153 uint32_t sid;
154 uint32_t cid;
155 } get_stats;
156 struct msg_transport_connect {
157 uint32_t non_blocking;
158 } ep_connect;
159 struct msg_transport_connect_through_host {
160 uint32_t host_no;
161 uint32_t non_blocking;
162 } ep_connect_through_host;
163 struct msg_transport_poll {
164 uint64_t ep_handle;
165 uint32_t timeout_ms;
166 } ep_poll;
167 struct msg_transport_disconnect {
168 uint64_t ep_handle;
169 } ep_disconnect;
170 struct msg_tgt_dscvr {
171 enum iscsi_tgt_dscvr type;
172 uint32_t host_no;
173 /*
174 * enable = 1 to establish a new connection
175 * with the server. enable = 0 to disconnect
176 * from the server. Used primarily to switch
177 * from one iSNS server to another.
178 */
179 uint32_t enable;
180 } tgt_dscvr;
181 struct msg_set_host_param {
182 uint32_t host_no;
183 uint32_t param; /* enum iscsi_host_param */
184 uint32_t len;
185 } set_host_param;
186 struct msg_set_path {
187 uint32_t host_no;
188 } set_path;
189 struct msg_set_iface_params {
190 uint32_t host_no;
191 uint32_t count;
192 } set_iface_params;
193 struct msg_iscsi_ping {
194 uint32_t host_no;
195 uint32_t iface_num;
196 uint32_t iface_type;
197 uint32_t payload_size;
198 uint32_t pid; /* unique ping id associated
199 with each ping request */
200 } iscsi_ping;
201 struct msg_get_chap {
202 uint32_t host_no;
203 uint32_t num_entries; /* number of CHAP entries
204 * on request, number of
205 * valid CHAP entries on
206 * response */
207 uint16_t chap_tbl_idx;
208 } get_chap;
209 struct msg_delete_chap {
210 uint32_t host_no;
211 uint16_t chap_tbl_idx;
212 } delete_chap;
213 } u;
214 union {
215 /* messages k -> u */
216 int retcode;
217 struct msg_create_session_ret {
218 uint32_t sid;
219 uint32_t host_no;
220 } c_session_ret;
221 struct msg_create_conn_ret {
222 uint32_t sid;
223 uint32_t cid;
224 } c_conn_ret;
225 struct msg_unbind_session {
226 uint32_t sid;
227 uint32_t host_no;
228 } unbind_session;
229 struct msg_recv_req {
230 uint32_t sid;
231 uint32_t cid;
232 uint64_t recv_handle;
233 } recv_req;
234 struct msg_conn_login {
235 uint32_t sid;
236 uint32_t cid;
237 uint32_t state; /* enum iscsi_conn_state */
238 } conn_login;
239 struct msg_conn_error {
240 uint32_t sid;
241 uint32_t cid;
242 uint32_t error; /* enum iscsi_err */
243 } connerror;
244 struct msg_session_destroyed {
245 uint32_t host_no;
246 uint32_t sid;
247 } d_session;
248 struct msg_transport_connect_ret {
249 uint64_t handle;
250 } ep_connect_ret;
251 struct msg_req_path {
252 uint32_t host_no;
253 } req_path;
254 struct msg_notify_if_down {
255 uint32_t host_no;
256 } notify_if_down;
257 struct msg_host_event {
258 uint32_t host_no;
259 uint32_t data_size;
260 enum iscsi_host_event_code code;
261 } host_event;
262 struct msg_ping_comp {
263 uint32_t host_no;
264 uint32_t status; /* enum
265 * iscsi_ping_status_code */
266 uint32_t pid; /* unique ping id associated
267 with each ping request */
268 uint32_t data_size;
269 } ping_comp;
270 } r;
271} __attribute__ ((aligned (sizeof(uint64_t))));
272
273enum iscsi_param_type {
274 ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
275 ISCSI_HOST_PARAM, /* iscsi_host_param */
276 ISCSI_NET_PARAM, /* iscsi_net_param */
277};
278
279struct iscsi_iface_param_info {
280 uint32_t iface_num; /* iface number, 0 - n */
281 uint32_t len; /* Actual length of the param */
282 uint16_t param; /* iscsi param value */
283 uint8_t iface_type; /* IPv4 or IPv6 */
284 uint8_t param_type; /* iscsi_param_type */
285 uint8_t value[0]; /* length sized value follows */
286} __packed;
287
288/*
289 * To keep the struct iscsi_uevent size the same for userspace code
290 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
291 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
292 * struct iscsi_uevent in the NETLINK_ISCSI message.
293 */
294struct iscsi_path {
295 uint64_t handle;
296 uint8_t mac_addr[6];
297 uint8_t mac_addr_old[6];
298 uint32_t ip_addr_len; /* 4 or 16 */
299 union {
300 struct in_addr v4_addr;
301 struct in6_addr v6_addr;
302 } src;
303 union {
304 struct in_addr v4_addr;
305 struct in6_addr v6_addr;
306 } dst;
307 uint16_t vlan_id;
308 uint16_t pmtu;
309} __attribute__ ((aligned (sizeof(uint64_t))));
310
311/* iscsi iface enabled/disabled setting */
312#define ISCSI_IFACE_DISABLE 0x01
313#define ISCSI_IFACE_ENABLE 0x02
314
315/* ipv4 bootproto */
316#define ISCSI_BOOTPROTO_STATIC 0x01
317#define ISCSI_BOOTPROTO_DHCP 0x02
318
319/* ipv6 addr autoconfig type */
320#define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
321#define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
322#define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
323
324/* ipv6 link local addr type */
325#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
326#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
327
328/* ipv6 router addr type */
329#define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
330#define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
331
332#define ISCSI_IFACE_TYPE_IPV4 0x01
333#define ISCSI_IFACE_TYPE_IPV6 0x02
334
335#define ISCSI_MAX_VLAN_ID 4095
336#define ISCSI_MAX_VLAN_PRIORITY 7
337
338/* iscsi vlan enable/disabled setting */
339#define ISCSI_VLAN_DISABLE 0x01
340#define ISCSI_VLAN_ENABLE 0x02
341
342/* iSCSI network params */
343enum iscsi_net_param {
344 ISCSI_NET_PARAM_IPV4_ADDR = 1,
345 ISCSI_NET_PARAM_IPV4_SUBNET = 2,
346 ISCSI_NET_PARAM_IPV4_GW = 3,
347 ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
348 ISCSI_NET_PARAM_MAC = 5,
349 ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
350 ISCSI_NET_PARAM_IPV6_ADDR = 7,
351 ISCSI_NET_PARAM_IPV6_ROUTER = 8,
352 ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
353 ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
354 ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
355 ISCSI_NET_PARAM_IFACE_ENABLE = 12,
356 ISCSI_NET_PARAM_VLAN_ID = 13,
357 ISCSI_NET_PARAM_VLAN_PRIORITY = 14,
358 ISCSI_NET_PARAM_VLAN_ENABLED = 15,
359 ISCSI_NET_PARAM_VLAN_TAG = 16,
360 ISCSI_NET_PARAM_IFACE_TYPE = 17,
361 ISCSI_NET_PARAM_IFACE_NAME = 18,
362 ISCSI_NET_PARAM_MTU = 19,
363 ISCSI_NET_PARAM_PORT = 20,
364};
365
366enum iscsi_conn_state {
367 ISCSI_CONN_STATE_FREE,
368 ISCSI_CONN_STATE_XPT_WAIT,
369 ISCSI_CONN_STATE_IN_LOGIN,
370 ISCSI_CONN_STATE_LOGGED_IN,
371 ISCSI_CONN_STATE_IN_LOGOUT,
372 ISCSI_CONN_STATE_LOGOUT_REQUESTED,
373 ISCSI_CONN_STATE_CLEANUP_WAIT,
374};
375
376/*
377 * Common error codes
378 */
379enum iscsi_err {
380 ISCSI_OK = 0,
381
382 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
383 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
384 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
385 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
386 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
387 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
388 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
389 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
390 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
391 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
392 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
393 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
394 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
395 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
396 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
397 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
398 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
399 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
400 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
401 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
402 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
403};
404
405/*
406 * iSCSI Parameters (RFC3720)
407 */
408enum iscsi_param {
409 /* passed in using netlink set param */
410 ISCSI_PARAM_MAX_RECV_DLENGTH,
411 ISCSI_PARAM_MAX_XMIT_DLENGTH,
412 ISCSI_PARAM_HDRDGST_EN,
413 ISCSI_PARAM_DATADGST_EN,
414 ISCSI_PARAM_INITIAL_R2T_EN,
415 ISCSI_PARAM_MAX_R2T,
416 ISCSI_PARAM_IMM_DATA_EN,
417 ISCSI_PARAM_FIRST_BURST,
418 ISCSI_PARAM_MAX_BURST,
419 ISCSI_PARAM_PDU_INORDER_EN,
420 ISCSI_PARAM_DATASEQ_INORDER_EN,
421 ISCSI_PARAM_ERL,
422 ISCSI_PARAM_IFMARKER_EN,
423 ISCSI_PARAM_OFMARKER_EN,
424 ISCSI_PARAM_EXP_STATSN,
425 ISCSI_PARAM_TARGET_NAME,
426 ISCSI_PARAM_TPGT,
427 ISCSI_PARAM_PERSISTENT_ADDRESS,
428 ISCSI_PARAM_PERSISTENT_PORT,
429 ISCSI_PARAM_SESS_RECOVERY_TMO,
430
431 /* passed in through bind conn using transport_fd */
432 ISCSI_PARAM_CONN_PORT,
433 ISCSI_PARAM_CONN_ADDRESS,
434
435 ISCSI_PARAM_USERNAME,
436 ISCSI_PARAM_USERNAME_IN,
437 ISCSI_PARAM_PASSWORD,
438 ISCSI_PARAM_PASSWORD_IN,
439
440 ISCSI_PARAM_FAST_ABORT,
441 ISCSI_PARAM_ABORT_TMO,
442 ISCSI_PARAM_LU_RESET_TMO,
443 ISCSI_PARAM_HOST_RESET_TMO,
444
445 ISCSI_PARAM_PING_TMO,
446 ISCSI_PARAM_RECV_TMO,
447
448 ISCSI_PARAM_IFACE_NAME,
449 ISCSI_PARAM_ISID,
450 ISCSI_PARAM_INITIATOR_NAME,
451
452 ISCSI_PARAM_TGT_RESET_TMO,
453 ISCSI_PARAM_TARGET_ALIAS,
454
455 ISCSI_PARAM_CHAP_IN_IDX,
456 ISCSI_PARAM_CHAP_OUT_IDX,
457 /* must always be last */
458 ISCSI_PARAM_MAX,
459};
460
461/* iSCSI HBA params */
462enum iscsi_host_param {
463 ISCSI_HOST_PARAM_HWADDRESS,
464 ISCSI_HOST_PARAM_INITIATOR_NAME,
465 ISCSI_HOST_PARAM_NETDEV_NAME,
466 ISCSI_HOST_PARAM_IPADDRESS,
467 ISCSI_HOST_PARAM_PORT_STATE,
468 ISCSI_HOST_PARAM_PORT_SPEED,
469 ISCSI_HOST_PARAM_MAX,
470};
471
472/* iSCSI port Speed */
473enum iscsi_port_speed {
474 ISCSI_PORT_SPEED_UNKNOWN = 0x1,
475 ISCSI_PORT_SPEED_10MBPS = 0x2,
476 ISCSI_PORT_SPEED_100MBPS = 0x4,
477 ISCSI_PORT_SPEED_1GBPS = 0x8,
478 ISCSI_PORT_SPEED_10GBPS = 0x10,
479};
480
481/* iSCSI port state */
482enum iscsi_port_state {
483 ISCSI_PORT_STATE_DOWN = 0x1,
484 ISCSI_PORT_STATE_UP = 0x2,
485};
486
487/* iSCSI PING status/error code */
488enum iscsi_ping_status_code {
489 ISCSI_PING_SUCCESS = 0,
490 ISCSI_PING_FW_DISABLED = 0x1,
491 ISCSI_PING_IPADDR_INVALID = 0x2,
492 ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID = 0x3,
493 ISCSI_PING_TIMEOUT = 0x4,
494 ISCSI_PING_INVALID_DEST_ADDR = 0x5,
495 ISCSI_PING_OVERSIZE_PACKET = 0x6,
496 ISCSI_PING_ICMP_ERROR = 0x7,
497 ISCSI_PING_MAX_REQ_EXCEEDED = 0x8,
498 ISCSI_PING_NO_ARP_RECEIVED = 0x9,
499};
500
501#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
502#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
503
504/*
505 * These flags presents iSCSI Data-Path capabilities.
506 */
507#define CAP_RECOVERY_L0 0x1
508#define CAP_RECOVERY_L1 0x2
509#define CAP_RECOVERY_L2 0x4
510#define CAP_MULTI_R2T 0x8
511#define CAP_HDRDGST 0x10
512#define CAP_DATADGST 0x20
513#define CAP_MULTI_CONN 0x40
514#define CAP_TEXT_NEGO 0x80
515#define CAP_MARKERS 0x100
516#define CAP_FW_DB 0x200
517#define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
518#define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
519#define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
520#define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
521 and verification */
522#define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */
523
524/*
525 * These flags describes reason of stop_conn() call
526 */
527#define STOP_CONN_TERM 0x1
528#define STOP_CONN_SUSPEND 0x2
529#define STOP_CONN_RECOVER 0x3
530
531#define ISCSI_STATS_CUSTOM_MAX 32
532#define ISCSI_STATS_CUSTOM_DESC_MAX 64
533struct iscsi_stats_custom {
534 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
535 uint64_t value;
536};
537
538/*
539 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
540 *
541 * Note: this structure contains counters collected on per-connection basis.
542 */
543struct iscsi_stats {
544 /* octets */
545 uint64_t txdata_octets;
546 uint64_t rxdata_octets;
547
548 /* xmit pdus */
549 uint32_t noptx_pdus;
550 uint32_t scsicmd_pdus;
551 uint32_t tmfcmd_pdus;
552 uint32_t login_pdus;
553 uint32_t text_pdus;
554 uint32_t dataout_pdus;
555 uint32_t logout_pdus;
556 uint32_t snack_pdus;
557
558 /* recv pdus */
559 uint32_t noprx_pdus;
560 uint32_t scsirsp_pdus;
561 uint32_t tmfrsp_pdus;
562 uint32_t textrsp_pdus;
563 uint32_t datain_pdus;
564 uint32_t logoutrsp_pdus;
565 uint32_t r2t_pdus;
566 uint32_t async_pdus;
567 uint32_t rjt_pdus;
568
569 /* errors */
570 uint32_t digest_err;
571 uint32_t timeout_err;
572
573 /*
574 * iSCSI Custom Statistics support, i.e. Transport could
575 * extend existing MIB statistics with its own specific statistics
576 * up to ISCSI_STATS_CUSTOM_MAX
577 */
578 uint32_t custom_length;
579 struct iscsi_stats_custom custom[0]
580 __attribute__ ((aligned (sizeof(uint64_t))));
581};
582
583enum chap_type_e {
584 CHAP_TYPE_OUT,
585 CHAP_TYPE_IN,
586};
587
588#define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
589#define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
590struct iscsi_chap_rec {
591 uint16_t chap_tbl_idx;
592 enum chap_type_e chap_type;
593 char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
594 uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
595 uint8_t password_length;
596};
597
598#endif