blob: e93831e87878110c0a77a17d6f96c737608dbfc8 [file] [log] [blame]
Alex Aizman39e84792005-08-04 19:31:00 -07001/*
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>
Michael Chan43514772009-06-08 18:14:41 -070025#include <linux/in.h>
26#include <linux/in6.h>
27
28#define ISCSI_NL_GRP_ISCSID 1
29#define ISCSI_NL_GRP_UIP 2
Alex Aizman39e84792005-08-04 19:31:00 -070030
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
Or Gerlitz264faaa2006-05-02 19:46:36 -050051 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
Mike Christie01cb2252006-06-28 12:00:22 -050055 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
Mike Christie1d9bf132007-05-30 12:57:11 -050056 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
Mike Christie26974782007-12-13 12:43:29 -060057 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
Mike Christie10eb0f02009-05-13 17:57:38 -050058 ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
59 ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19,
Mike Christie01cb2252006-06-28 12:00:22 -050060
Michael Chan43514772009-06-08 18:14:41 -070061 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20,
Mike Christie56c155b2011-07-25 13:48:37 -050062 ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21,
Michael Chan43514772009-06-08 18:14:41 -070063
Alex Aizman39e84792005-08-04 19:31:00 -070064 /* up events */
65 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
66 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
67 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
Mike Christie53cb8a12006-06-28 12:00:32 -050068 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
Mike Christie26974782007-12-13 12:43:29 -060069 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
70 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
Michael Chan43514772009-06-08 18:14:41 -070071
72 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
73 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
Alex Aizman39e84792005-08-04 19:31:00 -070074};
75
Mike Christie01cb2252006-06-28 12:00:22 -050076enum iscsi_tgt_dscvr {
77 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
78 ISCSI_TGT_DSCVR_ISNS = 2,
79 ISCSI_TGT_DSCVR_SLP = 3,
80};
81
Alex Aizman39e84792005-08-04 19:31:00 -070082struct iscsi_uevent {
83 uint32_t type; /* k/u events type */
84 uint32_t iferror; /* carries interface or resource errors */
85 uint64_t transport_handle;
86
87 union {
88 /* messages u -> k */
89 struct msg_create_session {
90 uint32_t initial_cmdsn;
Mike Christie15482712007-05-30 12:57:19 -050091 uint16_t cmds_max;
92 uint16_t queue_depth;
Alex Aizman39e84792005-08-04 19:31:00 -070093 } c_session;
Mike Christie40753ca2008-05-21 15:53:56 -050094 struct msg_create_bound_session {
Mike Christied82ff9be2008-05-21 15:54:13 -050095 uint64_t ep_handle;
Mike Christie40753ca2008-05-21 15:53:56 -050096 uint32_t initial_cmdsn;
97 uint16_t cmds_max;
98 uint16_t queue_depth;
99 } c_bound_session;
Alex Aizman39e84792005-08-04 19:31:00 -0700100 struct msg_destroy_session {
Alex Aizman39e84792005-08-04 19:31:00 -0700101 uint32_t sid;
102 } d_session;
103 struct msg_create_conn {
Alex Aizman39e84792005-08-04 19:31:00 -0700104 uint32_t sid;
Mike Christieb5c7a122006-04-06 21:13:33 -0500105 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700106 } c_conn;
107 struct msg_bind_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500108 uint32_t sid;
109 uint32_t cid;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500110 uint64_t transport_eph;
Alex Aizman39e84792005-08-04 19:31:00 -0700111 uint32_t is_leading;
112 } b_conn;
113 struct msg_destroy_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500114 uint32_t sid;
Alex Aizman39e84792005-08-04 19:31:00 -0700115 uint32_t cid;
116 } d_conn;
117 struct msg_send_pdu {
Mike Christieb5c7a122006-04-06 21:13:33 -0500118 uint32_t sid;
119 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700120 uint32_t hdr_size;
121 uint32_t data_size;
Alex Aizman39e84792005-08-04 19:31:00 -0700122 } send_pdu;
123 struct msg_set_param {
Mike Christieb5c7a122006-04-06 21:13:33 -0500124 uint32_t sid;
125 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700126 uint32_t param; /* enum iscsi_param */
Mike Christiefd7255f2006-04-06 21:13:36 -0500127 uint32_t len;
Alex Aizman39e84792005-08-04 19:31:00 -0700128 } set_param;
129 struct msg_start_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500130 uint32_t sid;
131 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700132 } start_conn;
133 struct msg_stop_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500134 uint32_t sid;
135 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700136 uint64_t conn_handle;
137 uint32_t flag;
138 } stop_conn;
139 struct msg_get_stats {
Mike Christieb5c7a122006-04-06 21:13:33 -0500140 uint32_t sid;
141 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700142 } get_stats;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500143 struct msg_transport_connect {
144 uint32_t non_blocking;
145 } ep_connect;
Mike Christie10eb0f02009-05-13 17:57:38 -0500146 struct msg_transport_connect_through_host {
147 uint32_t host_no;
148 uint32_t non_blocking;
149 } ep_connect_through_host;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500150 struct msg_transport_poll {
151 uint64_t ep_handle;
152 uint32_t timeout_ms;
153 } ep_poll;
154 struct msg_transport_disconnect {
155 uint64_t ep_handle;
156 } ep_disconnect;
Mike Christie01cb2252006-06-28 12:00:22 -0500157 struct msg_tgt_dscvr {
158 enum iscsi_tgt_dscvr type;
159 uint32_t host_no;
160 /*
161 * enable = 1 to establish a new connection
162 * with the server. enable = 0 to disconnect
163 * from the server. Used primarily to switch
164 * from one iSNS server to another.
165 */
166 uint32_t enable;
167 } tgt_dscvr;
Mike Christie1d9bf132007-05-30 12:57:11 -0500168 struct msg_set_host_param {
169 uint32_t host_no;
170 uint32_t param; /* enum iscsi_host_param */
171 uint32_t len;
172 } set_host_param;
Michael Chan43514772009-06-08 18:14:41 -0700173 struct msg_set_path {
174 uint32_t host_no;
175 } set_path;
Mike Christie56c155b2011-07-25 13:48:37 -0500176 struct msg_set_iface_params {
177 uint32_t host_no;
178 uint32_t count;
179 } set_iface_params;
Alex Aizman39e84792005-08-04 19:31:00 -0700180 } u;
181 union {
182 /* messages k -> u */
Alex Aizman39e84792005-08-04 19:31:00 -0700183 int retcode;
184 struct msg_create_session_ret {
Alex Aizman39e84792005-08-04 19:31:00 -0700185 uint32_t sid;
Mike Christieb5c7a122006-04-06 21:13:33 -0500186 uint32_t host_no;
Alex Aizman39e84792005-08-04 19:31:00 -0700187 } c_session_ret;
Mike Christieb5c7a122006-04-06 21:13:33 -0500188 struct msg_create_conn_ret {
189 uint32_t sid;
190 uint32_t cid;
191 } c_conn_ret;
Mike Christie26974782007-12-13 12:43:29 -0600192 struct msg_unbind_session {
193 uint32_t sid;
194 uint32_t host_no;
195 } unbind_session;
Alex Aizman39e84792005-08-04 19:31:00 -0700196 struct msg_recv_req {
Mike Christieb5c7a122006-04-06 21:13:33 -0500197 uint32_t sid;
198 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700199 uint64_t recv_handle;
Alex Aizman39e84792005-08-04 19:31:00 -0700200 } recv_req;
201 struct msg_conn_error {
Mike Christieb5c7a122006-04-06 21:13:33 -0500202 uint32_t sid;
203 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700204 uint32_t error; /* enum iscsi_err */
205 } connerror;
Mike Christie53cb8a12006-06-28 12:00:32 -0500206 struct msg_session_destroyed {
207 uint32_t host_no;
208 uint32_t sid;
209 } d_session;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500210 struct msg_transport_connect_ret {
211 uint64_t handle;
212 } ep_connect_ret;
Michael Chan43514772009-06-08 18:14:41 -0700213 struct msg_req_path {
214 uint32_t host_no;
215 } req_path;
216 struct msg_notify_if_down {
217 uint32_t host_no;
218 } notify_if_down;
Alex Aizman39e84792005-08-04 19:31:00 -0700219 } r;
220} __attribute__ ((aligned (sizeof(uint64_t))));
221
Mike Christie56c155b2011-07-25 13:48:37 -0500222enum iscsi_param_type {
223 ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
224 ISCSI_HOST_PARAM, /* iscsi_host_param */
225 ISCSI_NET_PARAM, /* iscsi_net_param */
226};
227
228struct iscsi_iface_param_info {
229 uint32_t iface_num; /* iface number, 0 - n */
230 uint32_t len; /* Actual length of the param */
231 uint16_t param; /* iscsi param value */
232 uint8_t iface_type; /* IPv4 or IPv6 */
233 uint8_t param_type; /* iscsi_param_type */
234 uint8_t value[0]; /* length sized value follows */
235} __packed;
236
Alex Aizman39e84792005-08-04 19:31:00 -0700237/*
Michael Chan43514772009-06-08 18:14:41 -0700238 * To keep the struct iscsi_uevent size the same for userspace code
239 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
240 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
241 * struct iscsi_uevent in the NETLINK_ISCSI message.
242 */
243struct iscsi_path {
244 uint64_t handle;
245 uint8_t mac_addr[6];
246 uint8_t mac_addr_old[6];
247 uint32_t ip_addr_len; /* 4 or 16 */
248 union {
249 struct in_addr v4_addr;
250 struct in6_addr v6_addr;
251 } src;
252 union {
253 struct in_addr v4_addr;
254 struct in6_addr v6_addr;
255 } dst;
256 uint16_t vlan_id;
257 uint16_t pmtu;
258} __attribute__ ((aligned (sizeof(uint64_t))));
259
Mike Christie56c155b2011-07-25 13:48:37 -0500260/* iscsi iface enabled/disabled setting */
261#define ISCSI_IFACE_DISABLE 0x01
262#define ISCSI_IFACE_ENABLE 0x02
263
264/* ipv4 bootproto */
265#define ISCSI_BOOTPROTO_STATIC 0x01
266#define ISCSI_BOOTPROTO_DHCP 0x02
267
268/* ipv6 addr autoconfig type */
269#define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
270#define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
271#define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
272
273/* ipv6 link local addr type */
274#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
275#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
276
277/* ipv6 router addr type */
278#define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
279#define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
280
281#define ISCSI_IFACE_TYPE_IPV4 0x01
282#define ISCSI_IFACE_TYPE_IPV6 0x02
283
284/* iSCSI network params */
285enum iscsi_net_param {
286 ISCSI_NET_PARAM_IPV4_ADDR = 1,
287 ISCSI_NET_PARAM_IPV4_SUBNET = 2,
288 ISCSI_NET_PARAM_IPV4_GW = 3,
289 ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
290 ISCSI_NET_PARAM_MAC = 5,
291 ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
292 ISCSI_NET_PARAM_IPV6_ADDR = 7,
293 ISCSI_NET_PARAM_IPV6_ROUTER = 8,
294 ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
295 ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
296 ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
297 ISCSI_NET_PARAM_IFACE_ENABLE = 12,
298 ISCSI_NET_PARAM_VLAN_ID = 13,
299 ISCSI_NET_IFACE_TYPE = 14,
300 ISCSI_NET_IFACE_NAME = 15,
301};
302
Michael Chan43514772009-06-08 18:14:41 -0700303/*
Alex Aizman39e84792005-08-04 19:31:00 -0700304 * Common error codes
305 */
306enum iscsi_err {
307 ISCSI_OK = 0,
308
309 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
310 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
311 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
312 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
313 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
314 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
315 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
316 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
317 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
318 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
319 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
320 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
321 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
322 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
323 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
Mike Christie7996a772006-04-06 21:13:41 -0500324 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
325 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
Mike Christiee5bd7b52008-09-24 11:46:10 -0500326 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
Mike Christie6f481e32008-09-24 11:46:13 -0500327 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
Mike Christied1af8a32009-08-20 15:11:02 -0500328 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
Mike Christiedf4da5c2010-12-31 02:22:18 -0600329 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
Alex Aizman39e84792005-08-04 19:31:00 -0700330};
331
332/*
333 * iSCSI Parameters (RFC3720)
334 */
335enum iscsi_param {
Mike Christiefd7255f2006-04-06 21:13:36 -0500336 /* passed in using netlink set param */
337 ISCSI_PARAM_MAX_RECV_DLENGTH,
338 ISCSI_PARAM_MAX_XMIT_DLENGTH,
339 ISCSI_PARAM_HDRDGST_EN,
340 ISCSI_PARAM_DATADGST_EN,
341 ISCSI_PARAM_INITIAL_R2T_EN,
342 ISCSI_PARAM_MAX_R2T,
343 ISCSI_PARAM_IMM_DATA_EN,
344 ISCSI_PARAM_FIRST_BURST,
345 ISCSI_PARAM_MAX_BURST,
346 ISCSI_PARAM_PDU_INORDER_EN,
347 ISCSI_PARAM_DATASEQ_INORDER_EN,
348 ISCSI_PARAM_ERL,
349 ISCSI_PARAM_IFMARKER_EN,
350 ISCSI_PARAM_OFMARKER_EN,
Mike Christie8d2860b2006-05-02 19:46:47 -0500351 ISCSI_PARAM_EXP_STATSN,
Mike Christiefd7255f2006-04-06 21:13:36 -0500352 ISCSI_PARAM_TARGET_NAME,
353 ISCSI_PARAM_TPGT,
354 ISCSI_PARAM_PERSISTENT_ADDRESS,
355 ISCSI_PARAM_PERSISTENT_PORT,
Mike Christie30a6c652006-04-06 21:13:39 -0500356 ISCSI_PARAM_SESS_RECOVERY_TMO,
Mike Christiefd7255f2006-04-06 21:13:36 -0500357
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300358 /* passed in through bind conn using transport_fd */
Mike Christiefd7255f2006-04-06 21:13:36 -0500359 ISCSI_PARAM_CONN_PORT,
360 ISCSI_PARAM_CONN_ADDRESS,
361
Mike Christieb2c64162007-05-30 12:57:16 -0500362 ISCSI_PARAM_USERNAME,
363 ISCSI_PARAM_USERNAME_IN,
364 ISCSI_PARAM_PASSWORD,
365 ISCSI_PARAM_PASSWORD_IN,
366
Mike Christie843c0a82007-12-13 12:43:20 -0600367 ISCSI_PARAM_FAST_ABORT,
Mike Christief6d51802007-12-13 12:43:30 -0600368 ISCSI_PARAM_ABORT_TMO,
369 ISCSI_PARAM_LU_RESET_TMO,
370 ISCSI_PARAM_HOST_RESET_TMO,
371
372 ISCSI_PARAM_PING_TMO,
373 ISCSI_PARAM_RECV_TMO,
Mike Christie88dfd342008-05-21 15:54:16 -0500374
375 ISCSI_PARAM_IFACE_NAME,
376 ISCSI_PARAM_ISID,
377 ISCSI_PARAM_INITIATOR_NAME,
Mike Christie3fe5ae82009-11-11 16:34:33 -0600378
379 ISCSI_PARAM_TGT_RESET_TMO,
Vikas Chaudhary3b2bef12010-07-10 14:51:30 +0530380 ISCSI_PARAM_TARGET_ALIAS,
Mike Christiefd7255f2006-04-06 21:13:36 -0500381 /* must always be last */
382 ISCSI_PARAM_MAX,
Alex Aizman39e84792005-08-04 19:31:00 -0700383};
Mike Christiefd7255f2006-04-06 21:13:36 -0500384
Mike Christie88dfd342008-05-21 15:54:16 -0500385#define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH)
386#define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH)
387#define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN)
388#define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN)
389#define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN)
390#define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T)
391#define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN)
392#define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST)
393#define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST)
394#define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN)
395#define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN)
396#define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL)
397#define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN)
398#define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN)
399#define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN)
400#define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME)
401#define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT)
402#define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS)
403#define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT)
404#define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO)
405#define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT)
406#define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS)
407#define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME)
408#define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN)
409#define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD)
410#define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN)
411#define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT)
412#define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO)
413#define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO)
414#define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO)
415#define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO)
416#define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO)
417#define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME)
418#define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID)
419#define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME)
Mike Christie3fe5ae82009-11-11 16:34:33 -0600420#define ISCSI_TGT_RESET_TMO (1ULL << ISCSI_PARAM_TGT_RESET_TMO)
Vikas Chaudhary3b2bef12010-07-10 14:51:30 +0530421#define ISCSI_TARGET_ALIAS (1ULL << ISCSI_PARAM_TARGET_ALIAS)
Alex Aizman39e84792005-08-04 19:31:00 -0700422
Mike Christie1819dc82007-05-30 12:57:08 -0500423/* iSCSI HBA params */
424enum iscsi_host_param {
425 ISCSI_HOST_PARAM_HWADDRESS,
Mike Christie8ad57812007-05-30 12:57:13 -0500426 ISCSI_HOST_PARAM_INITIATOR_NAME,
Mike Christied8196ed2007-05-30 12:57:25 -0500427 ISCSI_HOST_PARAM_NETDEV_NAME,
Mike Christie22236962007-05-30 12:57:24 -0500428 ISCSI_HOST_PARAM_IPADDRESS,
Mike Christie1819dc82007-05-30 12:57:08 -0500429 ISCSI_HOST_PARAM_MAX,
430};
431
Mike Christie88dfd342008-05-21 15:54:16 -0500432#define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS)
433#define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME)
434#define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME)
435#define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS)
Mike Christie1819dc82007-05-30 12:57:08 -0500436
Alex Aizman39e84792005-08-04 19:31:00 -0700437#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
438#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
Alex Aizman39e84792005-08-04 19:31:00 -0700439
440/*
441 * These flags presents iSCSI Data-Path capabilities.
442 */
443#define CAP_RECOVERY_L0 0x1
444#define CAP_RECOVERY_L1 0x2
445#define CAP_RECOVERY_L2 0x4
446#define CAP_MULTI_R2T 0x8
447#define CAP_HDRDGST 0x10
448#define CAP_DATADGST 0x20
449#define CAP_MULTI_CONN 0x40
450#define CAP_TEXT_NEGO 0x80
451#define CAP_MARKERS 0x100
Mike Christie0ab823d2007-05-30 12:57:22 -0500452#define CAP_FW_DB 0x200
Mike Christie63c62f12008-12-02 00:32:04 -0600453#define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
454#define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
455#define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
Mike Christie6df19a72008-12-02 00:32:16 -0600456#define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
457 and verification */
Alex Aizman39e84792005-08-04 19:31:00 -0700458
459/*
460 * These flags describes reason of stop_conn() call
461 */
462#define STOP_CONN_TERM 0x1
463#define STOP_CONN_SUSPEND 0x2
464#define STOP_CONN_RECOVER 0x3
465
466#define ISCSI_STATS_CUSTOM_MAX 32
467#define ISCSI_STATS_CUSTOM_DESC_MAX 64
468struct iscsi_stats_custom {
469 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
470 uint64_t value;
471};
472
473/*
474 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
475 *
476 * Note: this structure contains counters collected on per-connection basis.
477 */
478struct iscsi_stats {
479 /* octets */
480 uint64_t txdata_octets;
481 uint64_t rxdata_octets;
482
483 /* xmit pdus */
484 uint32_t noptx_pdus;
485 uint32_t scsicmd_pdus;
486 uint32_t tmfcmd_pdus;
487 uint32_t login_pdus;
488 uint32_t text_pdus;
489 uint32_t dataout_pdus;
490 uint32_t logout_pdus;
491 uint32_t snack_pdus;
492
493 /* recv pdus */
494 uint32_t noprx_pdus;
495 uint32_t scsirsp_pdus;
496 uint32_t tmfrsp_pdus;
497 uint32_t textrsp_pdus;
498 uint32_t datain_pdus;
499 uint32_t logoutrsp_pdus;
500 uint32_t r2t_pdus;
501 uint32_t async_pdus;
502 uint32_t rjt_pdus;
503
504 /* errors */
505 uint32_t digest_err;
506 uint32_t timeout_err;
507
508 /*
509 * iSCSI Custom Statistics support, i.e. Transport could
510 * extend existing MIB statistics with its own specific statistics
511 * up to ISCSI_STATS_CUSTOM_MAX
512 */
513 uint32_t custom_length;
514 struct iscsi_stats_custom custom[0]
515 __attribute__ ((aligned (sizeof(uint64_t))));
516};
517
518#endif