Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 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> |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 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 |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 30 | |
| 31 | #define UEVENT_BASE 10 |
| 32 | #define KEVENT_BASE 100 |
| 33 | #define ISCSI_ERR_BASE 1000 |
| 34 | |
| 35 | enum 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 Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 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 | |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 55 | ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 56 | ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16, |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 57 | ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17, |
Mike Christie | 10eb0f0 | 2009-05-13 17:57:38 -0500 | [diff] [blame] | 58 | ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18, |
| 59 | ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19, |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 60 | |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 61 | ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20, |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 62 | ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21, |
Vikas Chaudhary | ac20c7b | 2012-02-13 18:30:48 +0530 | [diff] [blame] | 63 | ISCSI_UEVENT_PING = UEVENT_BASE + 22, |
Nilesh Javali | 6260a5d | 2012-02-27 03:08:51 -0800 | [diff] [blame] | 64 | ISCSI_UEVENT_GET_CHAP = UEVENT_BASE + 23, |
| 65 | ISCSI_UEVENT_DELETE_CHAP = UEVENT_BASE + 24, |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 66 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 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, |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 71 | ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4, |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 72 | ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5, |
| 73 | ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6, |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 74 | |
| 75 | ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7, |
| 76 | ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8, |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 77 | ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9, |
Vikas Chaudhary | a11e254 | 2012-02-13 18:30:46 +0530 | [diff] [blame] | 78 | ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10, |
Vikas Chaudhary | ac20c7b | 2012-02-13 18:30:48 +0530 | [diff] [blame] | 79 | ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 82 | enum iscsi_tgt_dscvr { |
| 83 | ISCSI_TGT_DSCVR_SEND_TARGETS = 1, |
| 84 | ISCSI_TGT_DSCVR_ISNS = 2, |
| 85 | ISCSI_TGT_DSCVR_SLP = 3, |
| 86 | }; |
| 87 | |
Vikas Chaudhary | a11e254 | 2012-02-13 18:30:46 +0530 | [diff] [blame] | 88 | enum iscsi_host_event_code { |
| 89 | ISCSI_EVENT_LINKUP = 1, |
| 90 | ISCSI_EVENT_LINKDOWN, |
| 91 | /* must always be last */ |
| 92 | ISCSI_EVENT_MAX, |
| 93 | }; |
| 94 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 95 | struct 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; |
Mike Christie | 1548271 | 2007-05-30 12:57:19 -0500 | [diff] [blame] | 104 | uint16_t cmds_max; |
| 105 | uint16_t queue_depth; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 106 | } c_session; |
Mike Christie | 40753ca | 2008-05-21 15:53:56 -0500 | [diff] [blame] | 107 | struct msg_create_bound_session { |
Mike Christie | d82ff9be | 2008-05-21 15:54:13 -0500 | [diff] [blame] | 108 | uint64_t ep_handle; |
Mike Christie | 40753ca | 2008-05-21 15:53:56 -0500 | [diff] [blame] | 109 | uint32_t initial_cmdsn; |
| 110 | uint16_t cmds_max; |
| 111 | uint16_t queue_depth; |
| 112 | } c_bound_session; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 113 | struct msg_destroy_session { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 114 | uint32_t sid; |
| 115 | } d_session; |
| 116 | struct msg_create_conn { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 117 | uint32_t sid; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 118 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 119 | } c_conn; |
| 120 | struct msg_bind_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 121 | uint32_t sid; |
| 122 | uint32_t cid; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 123 | uint64_t transport_eph; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 124 | uint32_t is_leading; |
| 125 | } b_conn; |
| 126 | struct msg_destroy_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 127 | uint32_t sid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 128 | uint32_t cid; |
| 129 | } d_conn; |
| 130 | struct msg_send_pdu { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 131 | uint32_t sid; |
| 132 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 133 | uint32_t hdr_size; |
| 134 | uint32_t data_size; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 135 | } send_pdu; |
| 136 | struct msg_set_param { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 137 | uint32_t sid; |
| 138 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 139 | uint32_t param; /* enum iscsi_param */ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 140 | uint32_t len; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 141 | } set_param; |
| 142 | struct msg_start_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 143 | uint32_t sid; |
| 144 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 145 | } start_conn; |
| 146 | struct msg_stop_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 147 | uint32_t sid; |
| 148 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 149 | uint64_t conn_handle; |
| 150 | uint32_t flag; |
| 151 | } stop_conn; |
| 152 | struct msg_get_stats { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 153 | uint32_t sid; |
| 154 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 155 | } get_stats; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 156 | struct msg_transport_connect { |
| 157 | uint32_t non_blocking; |
| 158 | } ep_connect; |
Mike Christie | 10eb0f0 | 2009-05-13 17:57:38 -0500 | [diff] [blame] | 159 | struct msg_transport_connect_through_host { |
| 160 | uint32_t host_no; |
| 161 | uint32_t non_blocking; |
| 162 | } ep_connect_through_host; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 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; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 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; |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 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; |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 186 | struct msg_set_path { |
| 187 | uint32_t host_no; |
| 188 | } set_path; |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 189 | struct msg_set_iface_params { |
| 190 | uint32_t host_no; |
| 191 | uint32_t count; |
| 192 | } set_iface_params; |
Vikas Chaudhary | ac20c7b | 2012-02-13 18:30:48 +0530 | [diff] [blame] | 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; |
Nilesh Javali | 6260a5d | 2012-02-27 03:08:51 -0800 | [diff] [blame] | 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; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 213 | } u; |
| 214 | union { |
| 215 | /* messages k -> u */ |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 216 | int retcode; |
| 217 | struct msg_create_session_ret { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 218 | uint32_t sid; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 219 | uint32_t host_no; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 220 | } c_session_ret; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 221 | struct msg_create_conn_ret { |
| 222 | uint32_t sid; |
| 223 | uint32_t cid; |
| 224 | } c_conn_ret; |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 225 | struct msg_unbind_session { |
| 226 | uint32_t sid; |
| 227 | uint32_t host_no; |
| 228 | } unbind_session; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 229 | struct msg_recv_req { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 230 | uint32_t sid; |
| 231 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 232 | uint64_t recv_handle; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 233 | } recv_req; |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 234 | struct msg_conn_login { |
| 235 | uint32_t sid; |
| 236 | uint32_t cid; |
| 237 | uint32_t state; /* enum iscsi_conn_state */ |
| 238 | } conn_login; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 239 | struct msg_conn_error { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 240 | uint32_t sid; |
| 241 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 242 | uint32_t error; /* enum iscsi_err */ |
| 243 | } connerror; |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 244 | struct msg_session_destroyed { |
| 245 | uint32_t host_no; |
| 246 | uint32_t sid; |
| 247 | } d_session; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 248 | struct msg_transport_connect_ret { |
| 249 | uint64_t handle; |
| 250 | } ep_connect_ret; |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 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; |
Vikas Chaudhary | a11e254 | 2012-02-13 18:30:46 +0530 | [diff] [blame] | 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; |
Vikas Chaudhary | ac20c7b | 2012-02-13 18:30:48 +0530 | [diff] [blame] | 262 | struct msg_ping_comp { |
| 263 | uint32_t host_no; |
| 264 | uint32_t status; |
| 265 | uint32_t pid; /* unique ping id associated |
| 266 | with each ping request */ |
| 267 | uint32_t data_size; |
| 268 | } ping_comp; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 269 | } r; |
| 270 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 271 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 272 | enum iscsi_param_type { |
| 273 | ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */ |
| 274 | ISCSI_HOST_PARAM, /* iscsi_host_param */ |
| 275 | ISCSI_NET_PARAM, /* iscsi_net_param */ |
| 276 | }; |
| 277 | |
| 278 | struct iscsi_iface_param_info { |
| 279 | uint32_t iface_num; /* iface number, 0 - n */ |
| 280 | uint32_t len; /* Actual length of the param */ |
| 281 | uint16_t param; /* iscsi param value */ |
| 282 | uint8_t iface_type; /* IPv4 or IPv6 */ |
| 283 | uint8_t param_type; /* iscsi_param_type */ |
| 284 | uint8_t value[0]; /* length sized value follows */ |
| 285 | } __packed; |
| 286 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 287 | /* |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 288 | * To keep the struct iscsi_uevent size the same for userspace code |
| 289 | * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and |
| 290 | * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the |
| 291 | * struct iscsi_uevent in the NETLINK_ISCSI message. |
| 292 | */ |
| 293 | struct iscsi_path { |
| 294 | uint64_t handle; |
| 295 | uint8_t mac_addr[6]; |
| 296 | uint8_t mac_addr_old[6]; |
| 297 | uint32_t ip_addr_len; /* 4 or 16 */ |
| 298 | union { |
| 299 | struct in_addr v4_addr; |
| 300 | struct in6_addr v6_addr; |
| 301 | } src; |
| 302 | union { |
| 303 | struct in_addr v4_addr; |
| 304 | struct in6_addr v6_addr; |
| 305 | } dst; |
| 306 | uint16_t vlan_id; |
| 307 | uint16_t pmtu; |
| 308 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 309 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 310 | /* iscsi iface enabled/disabled setting */ |
| 311 | #define ISCSI_IFACE_DISABLE 0x01 |
| 312 | #define ISCSI_IFACE_ENABLE 0x02 |
| 313 | |
| 314 | /* ipv4 bootproto */ |
| 315 | #define ISCSI_BOOTPROTO_STATIC 0x01 |
| 316 | #define ISCSI_BOOTPROTO_DHCP 0x02 |
| 317 | |
| 318 | /* ipv6 addr autoconfig type */ |
| 319 | #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01 |
| 320 | #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02 |
| 321 | #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03 |
| 322 | |
| 323 | /* ipv6 link local addr type */ |
| 324 | #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01 |
| 325 | #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02 |
| 326 | |
| 327 | /* ipv6 router addr type */ |
| 328 | #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01 |
| 329 | #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02 |
| 330 | |
| 331 | #define ISCSI_IFACE_TYPE_IPV4 0x01 |
| 332 | #define ISCSI_IFACE_TYPE_IPV6 0x02 |
| 333 | |
Mike Christie | 4223b9e | 2011-07-25 13:48:47 -0500 | [diff] [blame] | 334 | #define ISCSI_MAX_VLAN_ID 4095 |
| 335 | #define ISCSI_MAX_VLAN_PRIORITY 7 |
| 336 | |
| 337 | /* iscsi vlan enable/disabled setting */ |
| 338 | #define ISCSI_VLAN_DISABLE 0x01 |
| 339 | #define ISCSI_VLAN_ENABLE 0x02 |
| 340 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 341 | /* iSCSI network params */ |
| 342 | enum iscsi_net_param { |
| 343 | ISCSI_NET_PARAM_IPV4_ADDR = 1, |
| 344 | ISCSI_NET_PARAM_IPV4_SUBNET = 2, |
| 345 | ISCSI_NET_PARAM_IPV4_GW = 3, |
| 346 | ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4, |
| 347 | ISCSI_NET_PARAM_MAC = 5, |
| 348 | ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6, |
| 349 | ISCSI_NET_PARAM_IPV6_ADDR = 7, |
| 350 | ISCSI_NET_PARAM_IPV6_ROUTER = 8, |
| 351 | ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9, |
| 352 | ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10, |
| 353 | ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11, |
| 354 | ISCSI_NET_PARAM_IFACE_ENABLE = 12, |
| 355 | ISCSI_NET_PARAM_VLAN_ID = 13, |
Mike Christie | 4223b9e | 2011-07-25 13:48:47 -0500 | [diff] [blame] | 356 | ISCSI_NET_PARAM_VLAN_PRIORITY = 14, |
| 357 | ISCSI_NET_PARAM_VLAN_ENABLED = 15, |
Mike Christie | 2d63673 | 2011-10-11 17:55:11 -0500 | [diff] [blame] | 358 | ISCSI_NET_PARAM_VLAN_TAG = 16, |
| 359 | ISCSI_NET_PARAM_IFACE_TYPE = 17, |
| 360 | ISCSI_NET_PARAM_IFACE_NAME = 18, |
| 361 | ISCSI_NET_PARAM_MTU = 19, |
| 362 | ISCSI_NET_PARAM_PORT = 20, |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 363 | }; |
| 364 | |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 365 | enum iscsi_conn_state { |
| 366 | ISCSI_CONN_STATE_FREE, |
| 367 | ISCSI_CONN_STATE_XPT_WAIT, |
| 368 | ISCSI_CONN_STATE_IN_LOGIN, |
| 369 | ISCSI_CONN_STATE_LOGGED_IN, |
| 370 | ISCSI_CONN_STATE_IN_LOGOUT, |
| 371 | ISCSI_CONN_STATE_LOGOUT_REQUESTED, |
| 372 | ISCSI_CONN_STATE_CLEANUP_WAIT, |
| 373 | }; |
| 374 | |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 375 | /* |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 376 | * Common error codes |
| 377 | */ |
| 378 | enum iscsi_err { |
| 379 | ISCSI_OK = 0, |
| 380 | |
| 381 | ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1, |
| 382 | ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2, |
| 383 | ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3, |
| 384 | ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4, |
| 385 | ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5, |
| 386 | ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6, |
| 387 | ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7, |
| 388 | ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8, |
| 389 | ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9, |
| 390 | ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10, |
| 391 | ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11, |
| 392 | ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12, |
| 393 | ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13, |
| 394 | ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14, |
| 395 | ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, |
Mike Christie | 7996a77 | 2006-04-06 21:13:41 -0500 | [diff] [blame] | 396 | ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16, |
| 397 | ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, |
Mike Christie | e5bd7b5 | 2008-09-24 11:46:10 -0500 | [diff] [blame] | 398 | ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, |
Mike Christie | 6f481e3 | 2008-09-24 11:46:13 -0500 | [diff] [blame] | 399 | ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, |
Mike Christie | d1af8a3 | 2009-08-20 15:11:02 -0500 | [diff] [blame] | 400 | ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, |
Mike Christie | df4da5c | 2010-12-31 02:22:18 -0600 | [diff] [blame] | 401 | ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 402 | }; |
| 403 | |
| 404 | /* |
| 405 | * iSCSI Parameters (RFC3720) |
| 406 | */ |
| 407 | enum iscsi_param { |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 408 | /* passed in using netlink set param */ |
| 409 | ISCSI_PARAM_MAX_RECV_DLENGTH, |
| 410 | ISCSI_PARAM_MAX_XMIT_DLENGTH, |
| 411 | ISCSI_PARAM_HDRDGST_EN, |
| 412 | ISCSI_PARAM_DATADGST_EN, |
| 413 | ISCSI_PARAM_INITIAL_R2T_EN, |
| 414 | ISCSI_PARAM_MAX_R2T, |
| 415 | ISCSI_PARAM_IMM_DATA_EN, |
| 416 | ISCSI_PARAM_FIRST_BURST, |
| 417 | ISCSI_PARAM_MAX_BURST, |
| 418 | ISCSI_PARAM_PDU_INORDER_EN, |
| 419 | ISCSI_PARAM_DATASEQ_INORDER_EN, |
| 420 | ISCSI_PARAM_ERL, |
| 421 | ISCSI_PARAM_IFMARKER_EN, |
| 422 | ISCSI_PARAM_OFMARKER_EN, |
Mike Christie | 8d2860b | 2006-05-02 19:46:47 -0500 | [diff] [blame] | 423 | ISCSI_PARAM_EXP_STATSN, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 424 | ISCSI_PARAM_TARGET_NAME, |
| 425 | ISCSI_PARAM_TPGT, |
| 426 | ISCSI_PARAM_PERSISTENT_ADDRESS, |
| 427 | ISCSI_PARAM_PERSISTENT_PORT, |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 428 | ISCSI_PARAM_SESS_RECOVERY_TMO, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 429 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 430 | /* passed in through bind conn using transport_fd */ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 431 | ISCSI_PARAM_CONN_PORT, |
| 432 | ISCSI_PARAM_CONN_ADDRESS, |
| 433 | |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 434 | ISCSI_PARAM_USERNAME, |
| 435 | ISCSI_PARAM_USERNAME_IN, |
| 436 | ISCSI_PARAM_PASSWORD, |
| 437 | ISCSI_PARAM_PASSWORD_IN, |
| 438 | |
Mike Christie | 843c0a8 | 2007-12-13 12:43:20 -0600 | [diff] [blame] | 439 | ISCSI_PARAM_FAST_ABORT, |
Mike Christie | f6d5180 | 2007-12-13 12:43:30 -0600 | [diff] [blame] | 440 | ISCSI_PARAM_ABORT_TMO, |
| 441 | ISCSI_PARAM_LU_RESET_TMO, |
| 442 | ISCSI_PARAM_HOST_RESET_TMO, |
| 443 | |
| 444 | ISCSI_PARAM_PING_TMO, |
| 445 | ISCSI_PARAM_RECV_TMO, |
Mike Christie | 88dfd34 | 2008-05-21 15:54:16 -0500 | [diff] [blame] | 446 | |
| 447 | ISCSI_PARAM_IFACE_NAME, |
| 448 | ISCSI_PARAM_ISID, |
| 449 | ISCSI_PARAM_INITIATOR_NAME, |
Mike Christie | 3fe5ae8 | 2009-11-11 16:34:33 -0600 | [diff] [blame] | 450 | |
| 451 | ISCSI_PARAM_TGT_RESET_TMO, |
Vikas Chaudhary | 3b2bef1 | 2010-07-10 14:51:30 +0530 | [diff] [blame] | 452 | ISCSI_PARAM_TARGET_ALIAS, |
Mike Christie | 3053495 | 2012-02-27 03:08:53 -0800 | [diff] [blame] | 453 | |
| 454 | ISCSI_PARAM_CHAP_IN_IDX, |
| 455 | ISCSI_PARAM_CHAP_OUT_IDX, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 456 | /* must always be last */ |
| 457 | ISCSI_PARAM_MAX, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 458 | }; |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 459 | |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 460 | /* iSCSI HBA params */ |
| 461 | enum iscsi_host_param { |
| 462 | ISCSI_HOST_PARAM_HWADDRESS, |
Mike Christie | 8ad5781 | 2007-05-30 12:57:13 -0500 | [diff] [blame] | 463 | ISCSI_HOST_PARAM_INITIATOR_NAME, |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 464 | ISCSI_HOST_PARAM_NETDEV_NAME, |
Mike Christie | 2223696 | 2007-05-30 12:57:24 -0500 | [diff] [blame] | 465 | ISCSI_HOST_PARAM_IPADDRESS, |
Vikas Chaudhary | aeddde2 | 2012-01-19 03:06:55 -0800 | [diff] [blame] | 466 | ISCSI_HOST_PARAM_PORT_STATE, |
| 467 | ISCSI_HOST_PARAM_PORT_SPEED, |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 468 | ISCSI_HOST_PARAM_MAX, |
| 469 | }; |
| 470 | |
Vikas Chaudhary | aeddde2 | 2012-01-19 03:06:55 -0800 | [diff] [blame] | 471 | /* iSCSI port Speed */ |
| 472 | enum iscsi_port_speed { |
| 473 | ISCSI_PORT_SPEED_UNKNOWN = 0x1, |
| 474 | ISCSI_PORT_SPEED_10MBPS = 0x2, |
| 475 | ISCSI_PORT_SPEED_100MBPS = 0x4, |
| 476 | ISCSI_PORT_SPEED_1GBPS = 0x8, |
| 477 | ISCSI_PORT_SPEED_10GBPS = 0x10, |
| 478 | }; |
| 479 | |
| 480 | /* iSCSI port state */ |
| 481 | enum iscsi_port_state { |
| 482 | ISCSI_PORT_STATE_DOWN = 0x1, |
| 483 | ISCSI_PORT_STATE_UP = 0x2, |
| 484 | }; |
| 485 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 486 | #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) |
| 487 | #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 488 | |
| 489 | /* |
| 490 | * These flags presents iSCSI Data-Path capabilities. |
| 491 | */ |
| 492 | #define CAP_RECOVERY_L0 0x1 |
| 493 | #define CAP_RECOVERY_L1 0x2 |
| 494 | #define CAP_RECOVERY_L2 0x4 |
| 495 | #define CAP_MULTI_R2T 0x8 |
| 496 | #define CAP_HDRDGST 0x10 |
| 497 | #define CAP_DATADGST 0x20 |
| 498 | #define CAP_MULTI_CONN 0x40 |
| 499 | #define CAP_TEXT_NEGO 0x80 |
| 500 | #define CAP_MARKERS 0x100 |
Mike Christie | 0ab823d | 2007-05-30 12:57:22 -0500 | [diff] [blame] | 501 | #define CAP_FW_DB 0x200 |
Mike Christie | 63c62f1 | 2008-12-02 00:32:04 -0600 | [diff] [blame] | 502 | #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */ |
| 503 | #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */ |
| 504 | #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */ |
Mike Christie | 6df19a7 | 2008-12-02 00:32:16 -0600 | [diff] [blame] | 505 | #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal, |
| 506 | and verification */ |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 507 | #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */ |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 508 | |
| 509 | /* |
| 510 | * These flags describes reason of stop_conn() call |
| 511 | */ |
| 512 | #define STOP_CONN_TERM 0x1 |
| 513 | #define STOP_CONN_SUSPEND 0x2 |
| 514 | #define STOP_CONN_RECOVER 0x3 |
| 515 | |
| 516 | #define ISCSI_STATS_CUSTOM_MAX 32 |
| 517 | #define ISCSI_STATS_CUSTOM_DESC_MAX 64 |
| 518 | struct iscsi_stats_custom { |
| 519 | char desc[ISCSI_STATS_CUSTOM_DESC_MAX]; |
| 520 | uint64_t value; |
| 521 | }; |
| 522 | |
| 523 | /* |
| 524 | * struct iscsi_stats - iSCSI Statistics (iSCSI MIB) |
| 525 | * |
| 526 | * Note: this structure contains counters collected on per-connection basis. |
| 527 | */ |
| 528 | struct iscsi_stats { |
| 529 | /* octets */ |
| 530 | uint64_t txdata_octets; |
| 531 | uint64_t rxdata_octets; |
| 532 | |
| 533 | /* xmit pdus */ |
| 534 | uint32_t noptx_pdus; |
| 535 | uint32_t scsicmd_pdus; |
| 536 | uint32_t tmfcmd_pdus; |
| 537 | uint32_t login_pdus; |
| 538 | uint32_t text_pdus; |
| 539 | uint32_t dataout_pdus; |
| 540 | uint32_t logout_pdus; |
| 541 | uint32_t snack_pdus; |
| 542 | |
| 543 | /* recv pdus */ |
| 544 | uint32_t noprx_pdus; |
| 545 | uint32_t scsirsp_pdus; |
| 546 | uint32_t tmfrsp_pdus; |
| 547 | uint32_t textrsp_pdus; |
| 548 | uint32_t datain_pdus; |
| 549 | uint32_t logoutrsp_pdus; |
| 550 | uint32_t r2t_pdus; |
| 551 | uint32_t async_pdus; |
| 552 | uint32_t rjt_pdus; |
| 553 | |
| 554 | /* errors */ |
| 555 | uint32_t digest_err; |
| 556 | uint32_t timeout_err; |
| 557 | |
| 558 | /* |
| 559 | * iSCSI Custom Statistics support, i.e. Transport could |
| 560 | * extend existing MIB statistics with its own specific statistics |
| 561 | * up to ISCSI_STATS_CUSTOM_MAX |
| 562 | */ |
| 563 | uint32_t custom_length; |
| 564 | struct iscsi_stats_custom custom[0] |
| 565 | __attribute__ ((aligned (sizeof(uint64_t)))); |
| 566 | }; |
| 567 | |
Nilesh Javali | 6260a5d | 2012-02-27 03:08:51 -0800 | [diff] [blame] | 568 | enum chap_type_e { |
| 569 | CHAP_TYPE_OUT, |
| 570 | CHAP_TYPE_IN, |
| 571 | }; |
| 572 | |
| 573 | #define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256 |
| 574 | #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256 |
| 575 | struct iscsi_chap_rec { |
| 576 | uint16_t chap_tbl_idx; |
| 577 | enum chap_type_e chap_type; |
| 578 | char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN]; |
| 579 | uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN]; |
| 580 | uint8_t password_length; |
| 581 | } __packed; |
| 582 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 583 | #endif |