blob: 5d6ed6cf12cc8c2c984e2565b028a55bedb001d8 [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,
Vikas Chaudharyac20c7b2012-02-13 18:30:48 +053063 ISCSI_UEVENT_PING = UEVENT_BASE + 22,
Nilesh Javali6260a5d2012-02-27 03:08:51 -080064 ISCSI_UEVENT_GET_CHAP = UEVENT_BASE + 23,
65 ISCSI_UEVENT_DELETE_CHAP = UEVENT_BASE + 24,
Adheer Chandravanshic6a4bb22013-03-22 07:41:29 -040066 ISCSI_UEVENT_SET_FLASHNODE_PARAMS = UEVENT_BASE + 25,
67 ISCSI_UEVENT_NEW_FLASHNODE = UEVENT_BASE + 26,
68 ISCSI_UEVENT_DEL_FLASHNODE = UEVENT_BASE + 27,
69 ISCSI_UEVENT_LOGIN_FLASHNODE = UEVENT_BASE + 28,
70 ISCSI_UEVENT_LOGOUT_FLASHNODE = UEVENT_BASE + 29,
71 ISCSI_UEVENT_LOGOUT_FLASHNODE_SID = UEVENT_BASE + 30,
Adheer Chandravanshi3af142f2013-09-17 07:54:48 -040072 ISCSI_UEVENT_SET_CHAP = UEVENT_BASE + 31,
Michael Chan43514772009-06-08 18:14:41 -070073
Alex Aizman39e84792005-08-04 19:31:00 -070074 /* up events */
75 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
76 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
77 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
Mike Christie53cb8a12006-06-28 12:00:32 -050078 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
Mike Christie26974782007-12-13 12:43:29 -060079 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
80 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
Michael Chan43514772009-06-08 18:14:41 -070081
82 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
83 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
Manish Rangankar17fa5752011-07-25 13:48:52 -050084 ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
Vikas Chaudharya11e2542012-02-13 18:30:46 +053085 ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
Vikas Chaudharyac20c7b2012-02-13 18:30:48 +053086 ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11,
Alex Aizman39e84792005-08-04 19:31:00 -070087};
88
Mike Christie01cb2252006-06-28 12:00:22 -050089enum iscsi_tgt_dscvr {
90 ISCSI_TGT_DSCVR_SEND_TARGETS = 1,
91 ISCSI_TGT_DSCVR_ISNS = 2,
92 ISCSI_TGT_DSCVR_SLP = 3,
93};
94
Vikas Chaudharya11e2542012-02-13 18:30:46 +053095enum iscsi_host_event_code {
96 ISCSI_EVENT_LINKUP = 1,
97 ISCSI_EVENT_LINKDOWN,
98 /* must always be last */
99 ISCSI_EVENT_MAX,
100};
101
Alex Aizman39e84792005-08-04 19:31:00 -0700102struct iscsi_uevent {
103 uint32_t type; /* k/u events type */
104 uint32_t iferror; /* carries interface or resource errors */
105 uint64_t transport_handle;
106
107 union {
108 /* messages u -> k */
109 struct msg_create_session {
110 uint32_t initial_cmdsn;
Mike Christie15482712007-05-30 12:57:19 -0500111 uint16_t cmds_max;
112 uint16_t queue_depth;
Alex Aizman39e84792005-08-04 19:31:00 -0700113 } c_session;
Mike Christie40753ca2008-05-21 15:53:56 -0500114 struct msg_create_bound_session {
Mike Christied82ff9be2008-05-21 15:54:13 -0500115 uint64_t ep_handle;
Mike Christie40753ca2008-05-21 15:53:56 -0500116 uint32_t initial_cmdsn;
117 uint16_t cmds_max;
118 uint16_t queue_depth;
119 } c_bound_session;
Alex Aizman39e84792005-08-04 19:31:00 -0700120 struct msg_destroy_session {
Alex Aizman39e84792005-08-04 19:31:00 -0700121 uint32_t sid;
122 } d_session;
123 struct msg_create_conn {
Alex Aizman39e84792005-08-04 19:31:00 -0700124 uint32_t sid;
Mike Christieb5c7a122006-04-06 21:13:33 -0500125 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700126 } c_conn;
127 struct msg_bind_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500128 uint32_t sid;
129 uint32_t cid;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500130 uint64_t transport_eph;
Alex Aizman39e84792005-08-04 19:31:00 -0700131 uint32_t is_leading;
132 } b_conn;
133 struct msg_destroy_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500134 uint32_t sid;
Alex Aizman39e84792005-08-04 19:31:00 -0700135 uint32_t cid;
136 } d_conn;
137 struct msg_send_pdu {
Mike Christieb5c7a122006-04-06 21:13:33 -0500138 uint32_t sid;
139 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700140 uint32_t hdr_size;
141 uint32_t data_size;
Alex Aizman39e84792005-08-04 19:31:00 -0700142 } send_pdu;
143 struct msg_set_param {
Mike Christieb5c7a122006-04-06 21:13:33 -0500144 uint32_t sid;
145 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700146 uint32_t param; /* enum iscsi_param */
Mike Christiefd7255f2006-04-06 21:13:36 -0500147 uint32_t len;
Alex Aizman39e84792005-08-04 19:31:00 -0700148 } set_param;
149 struct msg_start_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500150 uint32_t sid;
151 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700152 } start_conn;
153 struct msg_stop_conn {
Mike Christieb5c7a122006-04-06 21:13:33 -0500154 uint32_t sid;
155 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700156 uint64_t conn_handle;
157 uint32_t flag;
158 } stop_conn;
159 struct msg_get_stats {
Mike Christieb5c7a122006-04-06 21:13:33 -0500160 uint32_t sid;
161 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700162 } get_stats;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500163 struct msg_transport_connect {
164 uint32_t non_blocking;
165 } ep_connect;
Mike Christie10eb0f02009-05-13 17:57:38 -0500166 struct msg_transport_connect_through_host {
167 uint32_t host_no;
168 uint32_t non_blocking;
169 } ep_connect_through_host;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500170 struct msg_transport_poll {
171 uint64_t ep_handle;
172 uint32_t timeout_ms;
173 } ep_poll;
174 struct msg_transport_disconnect {
175 uint64_t ep_handle;
176 } ep_disconnect;
Mike Christie01cb2252006-06-28 12:00:22 -0500177 struct msg_tgt_dscvr {
178 enum iscsi_tgt_dscvr type;
179 uint32_t host_no;
180 /*
181 * enable = 1 to establish a new connection
182 * with the server. enable = 0 to disconnect
183 * from the server. Used primarily to switch
184 * from one iSNS server to another.
185 */
186 uint32_t enable;
187 } tgt_dscvr;
Mike Christie1d9bf132007-05-30 12:57:11 -0500188 struct msg_set_host_param {
189 uint32_t host_no;
190 uint32_t param; /* enum iscsi_host_param */
191 uint32_t len;
192 } set_host_param;
Michael Chan43514772009-06-08 18:14:41 -0700193 struct msg_set_path {
194 uint32_t host_no;
195 } set_path;
Mike Christie56c155b2011-07-25 13:48:37 -0500196 struct msg_set_iface_params {
197 uint32_t host_no;
198 uint32_t count;
199 } set_iface_params;
Vikas Chaudharyac20c7b2012-02-13 18:30:48 +0530200 struct msg_iscsi_ping {
201 uint32_t host_no;
202 uint32_t iface_num;
203 uint32_t iface_type;
204 uint32_t payload_size;
205 uint32_t pid; /* unique ping id associated
206 with each ping request */
207 } iscsi_ping;
Nilesh Javali6260a5d2012-02-27 03:08:51 -0800208 struct msg_get_chap {
209 uint32_t host_no;
210 uint32_t num_entries; /* number of CHAP entries
211 * on request, number of
212 * valid CHAP entries on
213 * response */
214 uint16_t chap_tbl_idx;
215 } get_chap;
216 struct msg_delete_chap {
217 uint32_t host_no;
218 uint16_t chap_tbl_idx;
219 } delete_chap;
Adheer Chandravanshic6a4bb22013-03-22 07:41:29 -0400220 struct msg_set_flashnode_param {
221 uint32_t host_no;
222 uint32_t flashnode_idx;
223 uint32_t count;
224 } set_flashnode;
225 struct msg_new_flashnode {
226 uint32_t host_no;
227 uint32_t len;
228 } new_flashnode;
229 struct msg_del_flashnode {
230 uint32_t host_no;
231 uint32_t flashnode_idx;
232 } del_flashnode;
233 struct msg_login_flashnode {
234 uint32_t host_no;
235 uint32_t flashnode_idx;
236 } login_flashnode;
237 struct msg_logout_flashnode {
238 uint32_t host_no;
239 uint32_t flashnode_idx;
240 } logout_flashnode;
241 struct msg_logout_flashnode_sid {
242 uint32_t host_no;
243 uint32_t sid;
244 } logout_flashnode_sid;
Alex Aizman39e84792005-08-04 19:31:00 -0700245 } u;
246 union {
247 /* messages k -> u */
Alex Aizman39e84792005-08-04 19:31:00 -0700248 int retcode;
249 struct msg_create_session_ret {
Alex Aizman39e84792005-08-04 19:31:00 -0700250 uint32_t sid;
Mike Christieb5c7a122006-04-06 21:13:33 -0500251 uint32_t host_no;
Alex Aizman39e84792005-08-04 19:31:00 -0700252 } c_session_ret;
Mike Christieb5c7a122006-04-06 21:13:33 -0500253 struct msg_create_conn_ret {
254 uint32_t sid;
255 uint32_t cid;
256 } c_conn_ret;
Mike Christie26974782007-12-13 12:43:29 -0600257 struct msg_unbind_session {
258 uint32_t sid;
259 uint32_t host_no;
260 } unbind_session;
Alex Aizman39e84792005-08-04 19:31:00 -0700261 struct msg_recv_req {
Mike Christieb5c7a122006-04-06 21:13:33 -0500262 uint32_t sid;
263 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700264 uint64_t recv_handle;
Alex Aizman39e84792005-08-04 19:31:00 -0700265 } recv_req;
Manish Rangankar17fa5752011-07-25 13:48:52 -0500266 struct msg_conn_login {
267 uint32_t sid;
268 uint32_t cid;
269 uint32_t state; /* enum iscsi_conn_state */
270 } conn_login;
Alex Aizman39e84792005-08-04 19:31:00 -0700271 struct msg_conn_error {
Mike Christieb5c7a122006-04-06 21:13:33 -0500272 uint32_t sid;
273 uint32_t cid;
Alex Aizman39e84792005-08-04 19:31:00 -0700274 uint32_t error; /* enum iscsi_err */
275 } connerror;
Mike Christie53cb8a12006-06-28 12:00:32 -0500276 struct msg_session_destroyed {
277 uint32_t host_no;
278 uint32_t sid;
279 } d_session;
Or Gerlitz264faaa2006-05-02 19:46:36 -0500280 struct msg_transport_connect_ret {
281 uint64_t handle;
282 } ep_connect_ret;
Michael Chan43514772009-06-08 18:14:41 -0700283 struct msg_req_path {
284 uint32_t host_no;
285 } req_path;
286 struct msg_notify_if_down {
287 uint32_t host_no;
288 } notify_if_down;
Vikas Chaudharya11e2542012-02-13 18:30:46 +0530289 struct msg_host_event {
290 uint32_t host_no;
291 uint32_t data_size;
292 enum iscsi_host_event_code code;
293 } host_event;
Vikas Chaudharyac20c7b2012-02-13 18:30:48 +0530294 struct msg_ping_comp {
295 uint32_t host_no;
Vikas Chaudhary1a590ca2012-03-06 04:16:04 -0800296 uint32_t status; /* enum
297 * iscsi_ping_status_code */
Vikas Chaudharyac20c7b2012-02-13 18:30:48 +0530298 uint32_t pid; /* unique ping id associated
299 with each ping request */
300 uint32_t data_size;
301 } ping_comp;
Adheer Chandravanshic6a4bb22013-03-22 07:41:29 -0400302 struct msg_new_flashnode_ret {
303 uint32_t flashnode_idx;
304 } new_flashnode_ret;
Alex Aizman39e84792005-08-04 19:31:00 -0700305 } r;
306} __attribute__ ((aligned (sizeof(uint64_t))));
307
Mike Christie56c155b2011-07-25 13:48:37 -0500308enum iscsi_param_type {
309 ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */
310 ISCSI_HOST_PARAM, /* iscsi_host_param */
311 ISCSI_NET_PARAM, /* iscsi_net_param */
Adheer Chandravanshic6a4bb22013-03-22 07:41:29 -0400312 ISCSI_FLASHNODE_PARAM, /* iscsi_flashnode_param */
Adheer Chandravanshi3af142f2013-09-17 07:54:48 -0400313 ISCSI_CHAP_PARAM, /* iscsi_chap_param */
Mike Christie56c155b2011-07-25 13:48:37 -0500314};
315
Adheer Chandravanshi3af142f2013-09-17 07:54:48 -0400316/* structure for minimalist usecase */
317struct iscsi_param_info {
318 uint32_t len; /* Actual length of the param value */
319 uint16_t param; /* iscsi param */
320 uint8_t value[0]; /* length sized value follows */
321} __packed;
322
Mike Christie56c155b2011-07-25 13:48:37 -0500323struct iscsi_iface_param_info {
324 uint32_t iface_num; /* iface number, 0 - n */
325 uint32_t len; /* Actual length of the param */
326 uint16_t param; /* iscsi param value */
327 uint8_t iface_type; /* IPv4 or IPv6 */
328 uint8_t param_type; /* iscsi_param_type */
329 uint8_t value[0]; /* length sized value follows */
330} __packed;
331
Alex Aizman39e84792005-08-04 19:31:00 -0700332/*
Michael Chan43514772009-06-08 18:14:41 -0700333 * To keep the struct iscsi_uevent size the same for userspace code
334 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
335 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
336 * struct iscsi_uevent in the NETLINK_ISCSI message.
337 */
338struct iscsi_path {
339 uint64_t handle;
340 uint8_t mac_addr[6];
341 uint8_t mac_addr_old[6];
342 uint32_t ip_addr_len; /* 4 or 16 */
343 union {
344 struct in_addr v4_addr;
345 struct in6_addr v6_addr;
346 } src;
347 union {
348 struct in_addr v4_addr;
349 struct in6_addr v6_addr;
350 } dst;
351 uint16_t vlan_id;
352 uint16_t pmtu;
353} __attribute__ ((aligned (sizeof(uint64_t))));
354
Mike Christie56c155b2011-07-25 13:48:37 -0500355/* iscsi iface enabled/disabled setting */
356#define ISCSI_IFACE_DISABLE 0x01
357#define ISCSI_IFACE_ENABLE 0x02
358
359/* ipv4 bootproto */
360#define ISCSI_BOOTPROTO_STATIC 0x01
361#define ISCSI_BOOTPROTO_DHCP 0x02
362
363/* ipv6 addr autoconfig type */
364#define ISCSI_IPV6_AUTOCFG_DISABLE 0x01
365#define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02
366#define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03
367
368/* ipv6 link local addr type */
369#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01
370#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02
371
372/* ipv6 router addr type */
373#define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01
374#define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02
375
376#define ISCSI_IFACE_TYPE_IPV4 0x01
377#define ISCSI_IFACE_TYPE_IPV6 0x02
378
Mike Christie4223b9e2011-07-25 13:48:47 -0500379#define ISCSI_MAX_VLAN_ID 4095
380#define ISCSI_MAX_VLAN_PRIORITY 7
381
382/* iscsi vlan enable/disabled setting */
383#define ISCSI_VLAN_DISABLE 0x01
384#define ISCSI_VLAN_ENABLE 0x02
385
Mike Christie56c155b2011-07-25 13:48:37 -0500386/* iSCSI network params */
387enum iscsi_net_param {
388 ISCSI_NET_PARAM_IPV4_ADDR = 1,
389 ISCSI_NET_PARAM_IPV4_SUBNET = 2,
390 ISCSI_NET_PARAM_IPV4_GW = 3,
391 ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4,
392 ISCSI_NET_PARAM_MAC = 5,
393 ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6,
394 ISCSI_NET_PARAM_IPV6_ADDR = 7,
395 ISCSI_NET_PARAM_IPV6_ROUTER = 8,
396 ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9,
397 ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10,
398 ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11,
399 ISCSI_NET_PARAM_IFACE_ENABLE = 12,
400 ISCSI_NET_PARAM_VLAN_ID = 13,
Mike Christie4223b9e2011-07-25 13:48:47 -0500401 ISCSI_NET_PARAM_VLAN_PRIORITY = 14,
402 ISCSI_NET_PARAM_VLAN_ENABLED = 15,
Mike Christie2d636732011-10-11 17:55:11 -0500403 ISCSI_NET_PARAM_VLAN_TAG = 16,
404 ISCSI_NET_PARAM_IFACE_TYPE = 17,
405 ISCSI_NET_PARAM_IFACE_NAME = 18,
406 ISCSI_NET_PARAM_MTU = 19,
407 ISCSI_NET_PARAM_PORT = 20,
Mike Christie56c155b2011-07-25 13:48:37 -0500408};
409
Manish Rangankar17fa5752011-07-25 13:48:52 -0500410enum iscsi_conn_state {
411 ISCSI_CONN_STATE_FREE,
412 ISCSI_CONN_STATE_XPT_WAIT,
413 ISCSI_CONN_STATE_IN_LOGIN,
414 ISCSI_CONN_STATE_LOGGED_IN,
415 ISCSI_CONN_STATE_IN_LOGOUT,
416 ISCSI_CONN_STATE_LOGOUT_REQUESTED,
417 ISCSI_CONN_STATE_CLEANUP_WAIT,
418};
419
Michael Chan43514772009-06-08 18:14:41 -0700420/*
Alex Aizman39e84792005-08-04 19:31:00 -0700421 * Common error codes
422 */
423enum iscsi_err {
424 ISCSI_OK = 0,
425
426 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1,
427 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2,
428 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3,
429 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4,
430 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5,
431 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6,
432 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7,
433 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8,
434 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9,
435 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10,
436 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11,
437 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12,
438 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13,
439 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14,
440 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15,
Mike Christie7996a772006-04-06 21:13:41 -0500441 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16,
442 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17,
Mike Christiee5bd7b52008-09-24 11:46:10 -0500443 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
Mike Christie6f481e32008-09-24 11:46:13 -0500444 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
Mike Christied1af8a32009-08-20 15:11:02 -0500445 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
Mike Christiedf4da5c2010-12-31 02:22:18 -0600446 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
Alex Aizman39e84792005-08-04 19:31:00 -0700447};
448
449/*
450 * iSCSI Parameters (RFC3720)
451 */
452enum iscsi_param {
Mike Christiefd7255f2006-04-06 21:13:36 -0500453 /* passed in using netlink set param */
454 ISCSI_PARAM_MAX_RECV_DLENGTH,
455 ISCSI_PARAM_MAX_XMIT_DLENGTH,
456 ISCSI_PARAM_HDRDGST_EN,
457 ISCSI_PARAM_DATADGST_EN,
458 ISCSI_PARAM_INITIAL_R2T_EN,
459 ISCSI_PARAM_MAX_R2T,
460 ISCSI_PARAM_IMM_DATA_EN,
461 ISCSI_PARAM_FIRST_BURST,
462 ISCSI_PARAM_MAX_BURST,
463 ISCSI_PARAM_PDU_INORDER_EN,
464 ISCSI_PARAM_DATASEQ_INORDER_EN,
465 ISCSI_PARAM_ERL,
466 ISCSI_PARAM_IFMARKER_EN,
467 ISCSI_PARAM_OFMARKER_EN,
Mike Christie8d2860b2006-05-02 19:46:47 -0500468 ISCSI_PARAM_EXP_STATSN,
Mike Christiefd7255f2006-04-06 21:13:36 -0500469 ISCSI_PARAM_TARGET_NAME,
470 ISCSI_PARAM_TPGT,
471 ISCSI_PARAM_PERSISTENT_ADDRESS,
472 ISCSI_PARAM_PERSISTENT_PORT,
Mike Christie30a6c652006-04-06 21:13:39 -0500473 ISCSI_PARAM_SESS_RECOVERY_TMO,
Mike Christiefd7255f2006-04-06 21:13:36 -0500474
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300475 /* passed in through bind conn using transport_fd */
Mike Christiefd7255f2006-04-06 21:13:36 -0500476 ISCSI_PARAM_CONN_PORT,
477 ISCSI_PARAM_CONN_ADDRESS,
478
Mike Christieb2c64162007-05-30 12:57:16 -0500479 ISCSI_PARAM_USERNAME,
480 ISCSI_PARAM_USERNAME_IN,
481 ISCSI_PARAM_PASSWORD,
482 ISCSI_PARAM_PASSWORD_IN,
483
Mike Christie843c0a82007-12-13 12:43:20 -0600484 ISCSI_PARAM_FAST_ABORT,
Mike Christief6d51802007-12-13 12:43:30 -0600485 ISCSI_PARAM_ABORT_TMO,
486 ISCSI_PARAM_LU_RESET_TMO,
487 ISCSI_PARAM_HOST_RESET_TMO,
488
489 ISCSI_PARAM_PING_TMO,
490 ISCSI_PARAM_RECV_TMO,
Mike Christie88dfd342008-05-21 15:54:16 -0500491
492 ISCSI_PARAM_IFACE_NAME,
493 ISCSI_PARAM_ISID,
494 ISCSI_PARAM_INITIATOR_NAME,
Mike Christie3fe5ae82009-11-11 16:34:33 -0600495
496 ISCSI_PARAM_TGT_RESET_TMO,
Vikas Chaudhary3b2bef12010-07-10 14:51:30 +0530497 ISCSI_PARAM_TARGET_ALIAS,
Mike Christie30534952012-02-27 03:08:53 -0800498
499 ISCSI_PARAM_CHAP_IN_IDX,
500 ISCSI_PARAM_CHAP_OUT_IDX,
Eddie Wai3b9373e2013-06-20 10:21:26 -0700501
502 ISCSI_PARAM_BOOT_ROOT,
503 ISCSI_PARAM_BOOT_NIC,
504 ISCSI_PARAM_BOOT_TARGET,
505
Adheer Chandravanshiae542ed2013-07-01 05:54:11 -0400506 ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
507 ISCSI_PARAM_DISCOVERY_SESS,
508 ISCSI_PARAM_PORTAL_TYPE,
509 ISCSI_PARAM_CHAP_AUTH_EN,
510 ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
511 ISCSI_PARAM_BIDI_CHAP_EN,
512 ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
513
514 ISCSI_PARAM_DEF_TIME2WAIT,
515 ISCSI_PARAM_DEF_TIME2RETAIN,
516 ISCSI_PARAM_MAX_SEGMENT_SIZE,
517 ISCSI_PARAM_STATSN,
518 ISCSI_PARAM_KEEPALIVE_TMO,
519 ISCSI_PARAM_LOCAL_PORT,
520 ISCSI_PARAM_TSID,
521 ISCSI_PARAM_DEF_TASKMGMT_TMO,
522
523 ISCSI_PARAM_TCP_TIMESTAMP_STAT,
524 ISCSI_PARAM_TCP_WSF_DISABLE,
525 ISCSI_PARAM_TCP_NAGLE_DISABLE,
526 ISCSI_PARAM_TCP_TIMER_SCALE,
527 ISCSI_PARAM_TCP_TIMESTAMP_EN,
528 ISCSI_PARAM_TCP_XMIT_WSF,
529 ISCSI_PARAM_TCP_RECV_WSF,
530 ISCSI_PARAM_IP_FRAGMENT_DISABLE,
531 ISCSI_PARAM_IPV4_TOS,
532 ISCSI_PARAM_IPV6_TC,
533 ISCSI_PARAM_IPV6_FLOW_LABEL,
534 ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
535
536 ISCSI_PARAM_DISCOVERY_PARENT_IDX,
537 ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
Mike Christiefd7255f2006-04-06 21:13:36 -0500538 /* must always be last */
539 ISCSI_PARAM_MAX,
Alex Aizman39e84792005-08-04 19:31:00 -0700540};
Mike Christiefd7255f2006-04-06 21:13:36 -0500541
Mike Christie1819dc82007-05-30 12:57:08 -0500542/* iSCSI HBA params */
543enum iscsi_host_param {
544 ISCSI_HOST_PARAM_HWADDRESS,
Mike Christie8ad57812007-05-30 12:57:13 -0500545 ISCSI_HOST_PARAM_INITIATOR_NAME,
Mike Christied8196ed2007-05-30 12:57:25 -0500546 ISCSI_HOST_PARAM_NETDEV_NAME,
Mike Christie22236962007-05-30 12:57:24 -0500547 ISCSI_HOST_PARAM_IPADDRESS,
Vikas Chaudharyaeddde22012-01-19 03:06:55 -0800548 ISCSI_HOST_PARAM_PORT_STATE,
549 ISCSI_HOST_PARAM_PORT_SPEED,
Mike Christie1819dc82007-05-30 12:57:08 -0500550 ISCSI_HOST_PARAM_MAX,
551};
552
Adheer Chandravanshi2902eb42013-03-25 08:08:31 -0400553/* portal type */
554#define PORTAL_TYPE_IPV4 "ipv4"
555#define PORTAL_TYPE_IPV6 "ipv6"
556
Adheer Chandravanshic6a4bb22013-03-22 07:41:29 -0400557/* iSCSI Flash Target params */
558enum iscsi_flashnode_param {
559 ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
560 ISCSI_FLASHNODE_PORTAL_TYPE,
561 ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
562 ISCSI_FLASHNODE_DISCOVERY_SESS,
563 ISCSI_FLASHNODE_ENTRY_EN,
564 ISCSI_FLASHNODE_HDR_DGST_EN,
565 ISCSI_FLASHNODE_DATA_DGST_EN,
566 ISCSI_FLASHNODE_IMM_DATA_EN,
567 ISCSI_FLASHNODE_INITIAL_R2T_EN,
568 ISCSI_FLASHNODE_DATASEQ_INORDER,
569 ISCSI_FLASHNODE_PDU_INORDER,
570 ISCSI_FLASHNODE_CHAP_AUTH_EN,
571 ISCSI_FLASHNODE_SNACK_REQ_EN,
572 ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
573 ISCSI_FLASHNODE_BIDI_CHAP_EN,
574 /* make authentication for discovery sessions optional */
575 ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
576 ISCSI_FLASHNODE_ERL,
577 ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
578 ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
579 ISCSI_FLASHNODE_TCP_WSF_DISABLE,
580 ISCSI_FLASHNODE_TCP_TIMER_SCALE,
581 ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
582 ISCSI_FLASHNODE_IP_FRAG_DISABLE,
583 ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
584 ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
585 ISCSI_FLASHNODE_FIRST_BURST,
586 ISCSI_FLASHNODE_DEF_TIME2WAIT,
587 ISCSI_FLASHNODE_DEF_TIME2RETAIN,
588 ISCSI_FLASHNODE_MAX_R2T,
589 ISCSI_FLASHNODE_KEEPALIVE_TMO,
590 ISCSI_FLASHNODE_ISID,
591 ISCSI_FLASHNODE_TSID,
592 ISCSI_FLASHNODE_PORT,
593 ISCSI_FLASHNODE_MAX_BURST,
594 ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
595 ISCSI_FLASHNODE_IPADDR,
596 ISCSI_FLASHNODE_ALIAS,
597 ISCSI_FLASHNODE_REDIRECT_IPADDR,
598 ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
599 ISCSI_FLASHNODE_LOCAL_PORT,
600 ISCSI_FLASHNODE_IPV4_TOS,
601 ISCSI_FLASHNODE_IPV6_TC,
602 ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
603 ISCSI_FLASHNODE_NAME,
604 ISCSI_FLASHNODE_TPGT,
605 ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
606 ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
607 ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
608 ISCSI_FLASHNODE_TCP_XMIT_WSF,
609 ISCSI_FLASHNODE_TCP_RECV_WSF,
610 ISCSI_FLASHNODE_CHAP_IN_IDX,
611 ISCSI_FLASHNODE_CHAP_OUT_IDX,
612 ISCSI_FLASHNODE_USERNAME,
613 ISCSI_FLASHNODE_USERNAME_IN,
614 ISCSI_FLASHNODE_PASSWORD,
615 ISCSI_FLASHNODE_PASSWORD_IN,
616 ISCSI_FLASHNODE_STATSN,
617 ISCSI_FLASHNODE_EXP_STATSN,
618 ISCSI_FLASHNODE_IS_BOOT_TGT,
619
620 ISCSI_FLASHNODE_MAX,
621};
622
623struct iscsi_flashnode_param_info {
624 uint32_t len; /* Actual length of the param */
625 uint16_t param; /* iscsi param value */
626 uint8_t value[0]; /* length sized value follows */
627} __packed;
628
629enum iscsi_discovery_parent_type {
630 ISCSI_DISC_PARENT_UNKNOWN = 0x1,
631 ISCSI_DISC_PARENT_SENDTGT = 0x2,
632 ISCSI_DISC_PARENT_ISNS = 0x3,
633};
634
Vikas Chaudharyaeddde22012-01-19 03:06:55 -0800635/* iSCSI port Speed */
636enum iscsi_port_speed {
637 ISCSI_PORT_SPEED_UNKNOWN = 0x1,
638 ISCSI_PORT_SPEED_10MBPS = 0x2,
639 ISCSI_PORT_SPEED_100MBPS = 0x4,
640 ISCSI_PORT_SPEED_1GBPS = 0x8,
641 ISCSI_PORT_SPEED_10GBPS = 0x10,
642};
643
644/* iSCSI port state */
645enum iscsi_port_state {
646 ISCSI_PORT_STATE_DOWN = 0x1,
647 ISCSI_PORT_STATE_UP = 0x2,
648};
649
Vikas Chaudhary1a590ca2012-03-06 04:16:04 -0800650/* iSCSI PING status/error code */
651enum iscsi_ping_status_code {
652 ISCSI_PING_SUCCESS = 0,
653 ISCSI_PING_FW_DISABLED = 0x1,
654 ISCSI_PING_IPADDR_INVALID = 0x2,
655 ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID = 0x3,
656 ISCSI_PING_TIMEOUT = 0x4,
657 ISCSI_PING_INVALID_DEST_ADDR = 0x5,
658 ISCSI_PING_OVERSIZE_PACKET = 0x6,
659 ISCSI_PING_ICMP_ERROR = 0x7,
660 ISCSI_PING_MAX_REQ_EXCEEDED = 0x8,
661 ISCSI_PING_NO_ARP_RECEIVED = 0x9,
662};
663
Alex Aizman39e84792005-08-04 19:31:00 -0700664#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
665#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
Alex Aizman39e84792005-08-04 19:31:00 -0700666
667/*
668 * These flags presents iSCSI Data-Path capabilities.
669 */
670#define CAP_RECOVERY_L0 0x1
671#define CAP_RECOVERY_L1 0x2
672#define CAP_RECOVERY_L2 0x4
673#define CAP_MULTI_R2T 0x8
674#define CAP_HDRDGST 0x10
675#define CAP_DATADGST 0x20
676#define CAP_MULTI_CONN 0x40
677#define CAP_TEXT_NEGO 0x80
678#define CAP_MARKERS 0x100
Mike Christie0ab823d2007-05-30 12:57:22 -0500679#define CAP_FW_DB 0x200
Mike Christie63c62f12008-12-02 00:32:04 -0600680#define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
681#define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
682#define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
Mike Christie6df19a72008-12-02 00:32:16 -0600683#define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
684 and verification */
Manish Rangankar17fa5752011-07-25 13:48:52 -0500685#define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */
Alex Aizman39e84792005-08-04 19:31:00 -0700686
687/*
688 * These flags describes reason of stop_conn() call
689 */
690#define STOP_CONN_TERM 0x1
691#define STOP_CONN_SUSPEND 0x2
692#define STOP_CONN_RECOVER 0x3
693
694#define ISCSI_STATS_CUSTOM_MAX 32
695#define ISCSI_STATS_CUSTOM_DESC_MAX 64
696struct iscsi_stats_custom {
697 char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
698 uint64_t value;
699};
700
701/*
702 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
703 *
704 * Note: this structure contains counters collected on per-connection basis.
705 */
706struct iscsi_stats {
707 /* octets */
708 uint64_t txdata_octets;
709 uint64_t rxdata_octets;
710
711 /* xmit pdus */
712 uint32_t noptx_pdus;
713 uint32_t scsicmd_pdus;
714 uint32_t tmfcmd_pdus;
715 uint32_t login_pdus;
716 uint32_t text_pdus;
717 uint32_t dataout_pdus;
718 uint32_t logout_pdus;
719 uint32_t snack_pdus;
720
721 /* recv pdus */
722 uint32_t noprx_pdus;
723 uint32_t scsirsp_pdus;
724 uint32_t tmfrsp_pdus;
725 uint32_t textrsp_pdus;
726 uint32_t datain_pdus;
727 uint32_t logoutrsp_pdus;
728 uint32_t r2t_pdus;
729 uint32_t async_pdus;
730 uint32_t rjt_pdus;
731
732 /* errors */
733 uint32_t digest_err;
734 uint32_t timeout_err;
735
736 /*
737 * iSCSI Custom Statistics support, i.e. Transport could
738 * extend existing MIB statistics with its own specific statistics
739 * up to ISCSI_STATS_CUSTOM_MAX
740 */
741 uint32_t custom_length;
742 struct iscsi_stats_custom custom[0]
743 __attribute__ ((aligned (sizeof(uint64_t))));
744};
745
Nilesh Javali6260a5d2012-02-27 03:08:51 -0800746enum chap_type_e {
747 CHAP_TYPE_OUT,
748 CHAP_TYPE_IN,
749};
750
Adheer Chandravanshi3af142f2013-09-17 07:54:48 -0400751enum iscsi_chap_param {
752 ISCSI_CHAP_PARAM_INDEX,
753 ISCSI_CHAP_PARAM_CHAP_TYPE,
754 ISCSI_CHAP_PARAM_USERNAME,
755 ISCSI_CHAP_PARAM_PASSWORD,
756 ISCSI_CHAP_PARAM_PASSWORD_LEN
757};
758
Nilesh Javali6260a5d2012-02-27 03:08:51 -0800759#define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
760#define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
761struct iscsi_chap_rec {
762 uint16_t chap_tbl_idx;
763 enum chap_type_e chap_type;
764 char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
765 uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
766 uint8_t password_length;
Vikas Chaudhary5a5a15f2012-03-06 04:16:05 -0800767};
Nilesh Javali6260a5d2012-02-27 03:08:51 -0800768
Alex Aizman39e84792005-08-04 19:31:00 -0700769#endif