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, |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 63 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 64 | /* 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 Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 68 | ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4, |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 69 | ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5, |
| 70 | ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6, |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 71 | |
| 72 | ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7, |
| 73 | ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8, |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 74 | ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 77 | enum iscsi_tgt_dscvr { |
| 78 | ISCSI_TGT_DSCVR_SEND_TARGETS = 1, |
| 79 | ISCSI_TGT_DSCVR_ISNS = 2, |
| 80 | ISCSI_TGT_DSCVR_SLP = 3, |
| 81 | }; |
| 82 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 83 | struct iscsi_uevent { |
| 84 | uint32_t type; /* k/u events type */ |
| 85 | uint32_t iferror; /* carries interface or resource errors */ |
| 86 | uint64_t transport_handle; |
| 87 | |
| 88 | union { |
| 89 | /* messages u -> k */ |
| 90 | struct msg_create_session { |
| 91 | uint32_t initial_cmdsn; |
Mike Christie | 1548271 | 2007-05-30 12:57:19 -0500 | [diff] [blame] | 92 | uint16_t cmds_max; |
| 93 | uint16_t queue_depth; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 94 | } c_session; |
Mike Christie | 40753ca | 2008-05-21 15:53:56 -0500 | [diff] [blame] | 95 | struct msg_create_bound_session { |
Mike Christie | d82ff9be | 2008-05-21 15:54:13 -0500 | [diff] [blame] | 96 | uint64_t ep_handle; |
Mike Christie | 40753ca | 2008-05-21 15:53:56 -0500 | [diff] [blame] | 97 | uint32_t initial_cmdsn; |
| 98 | uint16_t cmds_max; |
| 99 | uint16_t queue_depth; |
| 100 | } c_bound_session; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 101 | struct msg_destroy_session { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 102 | uint32_t sid; |
| 103 | } d_session; |
| 104 | struct msg_create_conn { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 105 | uint32_t sid; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 106 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 107 | } c_conn; |
| 108 | struct msg_bind_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 109 | uint32_t sid; |
| 110 | uint32_t cid; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 111 | uint64_t transport_eph; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 112 | uint32_t is_leading; |
| 113 | } b_conn; |
| 114 | struct msg_destroy_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 115 | uint32_t sid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 116 | uint32_t cid; |
| 117 | } d_conn; |
| 118 | struct msg_send_pdu { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 119 | uint32_t sid; |
| 120 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 121 | uint32_t hdr_size; |
| 122 | uint32_t data_size; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 123 | } send_pdu; |
| 124 | struct msg_set_param { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 125 | uint32_t sid; |
| 126 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 127 | uint32_t param; /* enum iscsi_param */ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 128 | uint32_t len; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 129 | } set_param; |
| 130 | struct msg_start_conn { |
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 | } start_conn; |
| 134 | struct msg_stop_conn { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 135 | uint32_t sid; |
| 136 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 137 | uint64_t conn_handle; |
| 138 | uint32_t flag; |
| 139 | } stop_conn; |
| 140 | struct msg_get_stats { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 141 | uint32_t sid; |
| 142 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 143 | } get_stats; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 144 | struct msg_transport_connect { |
| 145 | uint32_t non_blocking; |
| 146 | } ep_connect; |
Mike Christie | 10eb0f0 | 2009-05-13 17:57:38 -0500 | [diff] [blame] | 147 | struct msg_transport_connect_through_host { |
| 148 | uint32_t host_no; |
| 149 | uint32_t non_blocking; |
| 150 | } ep_connect_through_host; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 151 | struct msg_transport_poll { |
| 152 | uint64_t ep_handle; |
| 153 | uint32_t timeout_ms; |
| 154 | } ep_poll; |
| 155 | struct msg_transport_disconnect { |
| 156 | uint64_t ep_handle; |
| 157 | } ep_disconnect; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 158 | struct msg_tgt_dscvr { |
| 159 | enum iscsi_tgt_dscvr type; |
| 160 | uint32_t host_no; |
| 161 | /* |
| 162 | * enable = 1 to establish a new connection |
| 163 | * with the server. enable = 0 to disconnect |
| 164 | * from the server. Used primarily to switch |
| 165 | * from one iSNS server to another. |
| 166 | */ |
| 167 | uint32_t enable; |
| 168 | } tgt_dscvr; |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 169 | struct msg_set_host_param { |
| 170 | uint32_t host_no; |
| 171 | uint32_t param; /* enum iscsi_host_param */ |
| 172 | uint32_t len; |
| 173 | } set_host_param; |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 174 | struct msg_set_path { |
| 175 | uint32_t host_no; |
| 176 | } set_path; |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 177 | struct msg_set_iface_params { |
| 178 | uint32_t host_no; |
| 179 | uint32_t count; |
| 180 | } set_iface_params; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 181 | } u; |
| 182 | union { |
| 183 | /* messages k -> u */ |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 184 | int retcode; |
| 185 | struct msg_create_session_ret { |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 186 | uint32_t sid; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 187 | uint32_t host_no; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 188 | } c_session_ret; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 189 | struct msg_create_conn_ret { |
| 190 | uint32_t sid; |
| 191 | uint32_t cid; |
| 192 | } c_conn_ret; |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 193 | struct msg_unbind_session { |
| 194 | uint32_t sid; |
| 195 | uint32_t host_no; |
| 196 | } unbind_session; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 197 | struct msg_recv_req { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 198 | uint32_t sid; |
| 199 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 200 | uint64_t recv_handle; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 201 | } recv_req; |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 202 | struct msg_conn_login { |
| 203 | uint32_t sid; |
| 204 | uint32_t cid; |
| 205 | uint32_t state; /* enum iscsi_conn_state */ |
| 206 | } conn_login; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 207 | struct msg_conn_error { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 208 | uint32_t sid; |
| 209 | uint32_t cid; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 210 | uint32_t error; /* enum iscsi_err */ |
| 211 | } connerror; |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 212 | struct msg_session_destroyed { |
| 213 | uint32_t host_no; |
| 214 | uint32_t sid; |
| 215 | } d_session; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 216 | struct msg_transport_connect_ret { |
| 217 | uint64_t handle; |
| 218 | } ep_connect_ret; |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 219 | struct msg_req_path { |
| 220 | uint32_t host_no; |
| 221 | } req_path; |
| 222 | struct msg_notify_if_down { |
| 223 | uint32_t host_no; |
| 224 | } notify_if_down; |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 225 | } r; |
| 226 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 227 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 228 | enum iscsi_param_type { |
| 229 | ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */ |
| 230 | ISCSI_HOST_PARAM, /* iscsi_host_param */ |
| 231 | ISCSI_NET_PARAM, /* iscsi_net_param */ |
| 232 | }; |
| 233 | |
| 234 | struct iscsi_iface_param_info { |
| 235 | uint32_t iface_num; /* iface number, 0 - n */ |
| 236 | uint32_t len; /* Actual length of the param */ |
| 237 | uint16_t param; /* iscsi param value */ |
| 238 | uint8_t iface_type; /* IPv4 or IPv6 */ |
| 239 | uint8_t param_type; /* iscsi_param_type */ |
| 240 | uint8_t value[0]; /* length sized value follows */ |
| 241 | } __packed; |
| 242 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 243 | /* |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 244 | * To keep the struct iscsi_uevent size the same for userspace code |
| 245 | * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and |
| 246 | * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the |
| 247 | * struct iscsi_uevent in the NETLINK_ISCSI message. |
| 248 | */ |
| 249 | struct iscsi_path { |
| 250 | uint64_t handle; |
| 251 | uint8_t mac_addr[6]; |
| 252 | uint8_t mac_addr_old[6]; |
| 253 | uint32_t ip_addr_len; /* 4 or 16 */ |
| 254 | union { |
| 255 | struct in_addr v4_addr; |
| 256 | struct in6_addr v6_addr; |
| 257 | } src; |
| 258 | union { |
| 259 | struct in_addr v4_addr; |
| 260 | struct in6_addr v6_addr; |
| 261 | } dst; |
| 262 | uint16_t vlan_id; |
| 263 | uint16_t pmtu; |
| 264 | } __attribute__ ((aligned (sizeof(uint64_t)))); |
| 265 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 266 | /* iscsi iface enabled/disabled setting */ |
| 267 | #define ISCSI_IFACE_DISABLE 0x01 |
| 268 | #define ISCSI_IFACE_ENABLE 0x02 |
| 269 | |
| 270 | /* ipv4 bootproto */ |
| 271 | #define ISCSI_BOOTPROTO_STATIC 0x01 |
| 272 | #define ISCSI_BOOTPROTO_DHCP 0x02 |
| 273 | |
| 274 | /* ipv6 addr autoconfig type */ |
| 275 | #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01 |
| 276 | #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02 |
| 277 | #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03 |
| 278 | |
| 279 | /* ipv6 link local addr type */ |
| 280 | #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01 |
| 281 | #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02 |
| 282 | |
| 283 | /* ipv6 router addr type */ |
| 284 | #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01 |
| 285 | #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02 |
| 286 | |
| 287 | #define ISCSI_IFACE_TYPE_IPV4 0x01 |
| 288 | #define ISCSI_IFACE_TYPE_IPV6 0x02 |
| 289 | |
Mike Christie | 4223b9e | 2011-07-25 13:48:47 -0500 | [diff] [blame] | 290 | #define ISCSI_MAX_VLAN_ID 4095 |
| 291 | #define ISCSI_MAX_VLAN_PRIORITY 7 |
| 292 | |
| 293 | /* iscsi vlan enable/disabled setting */ |
| 294 | #define ISCSI_VLAN_DISABLE 0x01 |
| 295 | #define ISCSI_VLAN_ENABLE 0x02 |
| 296 | |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 297 | /* iSCSI network params */ |
| 298 | enum iscsi_net_param { |
| 299 | ISCSI_NET_PARAM_IPV4_ADDR = 1, |
| 300 | ISCSI_NET_PARAM_IPV4_SUBNET = 2, |
| 301 | ISCSI_NET_PARAM_IPV4_GW = 3, |
| 302 | ISCSI_NET_PARAM_IPV4_BOOTPROTO = 4, |
| 303 | ISCSI_NET_PARAM_MAC = 5, |
| 304 | ISCSI_NET_PARAM_IPV6_LINKLOCAL = 6, |
| 305 | ISCSI_NET_PARAM_IPV6_ADDR = 7, |
| 306 | ISCSI_NET_PARAM_IPV6_ROUTER = 8, |
| 307 | ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG = 9, |
| 308 | ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG = 10, |
| 309 | ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG = 11, |
| 310 | ISCSI_NET_PARAM_IFACE_ENABLE = 12, |
| 311 | ISCSI_NET_PARAM_VLAN_ID = 13, |
Mike Christie | 4223b9e | 2011-07-25 13:48:47 -0500 | [diff] [blame] | 312 | ISCSI_NET_PARAM_VLAN_PRIORITY = 14, |
| 313 | ISCSI_NET_PARAM_VLAN_ENABLED = 15, |
Mike Christie | 2d63673 | 2011-10-11 17:55:11 -0500 | [diff] [blame] | 314 | ISCSI_NET_PARAM_VLAN_TAG = 16, |
| 315 | ISCSI_NET_PARAM_IFACE_TYPE = 17, |
| 316 | ISCSI_NET_PARAM_IFACE_NAME = 18, |
| 317 | ISCSI_NET_PARAM_MTU = 19, |
| 318 | ISCSI_NET_PARAM_PORT = 20, |
Mike Christie | 56c155b | 2011-07-25 13:48:37 -0500 | [diff] [blame] | 319 | }; |
| 320 | |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 321 | enum iscsi_conn_state { |
| 322 | ISCSI_CONN_STATE_FREE, |
| 323 | ISCSI_CONN_STATE_XPT_WAIT, |
| 324 | ISCSI_CONN_STATE_IN_LOGIN, |
| 325 | ISCSI_CONN_STATE_LOGGED_IN, |
| 326 | ISCSI_CONN_STATE_IN_LOGOUT, |
| 327 | ISCSI_CONN_STATE_LOGOUT_REQUESTED, |
| 328 | ISCSI_CONN_STATE_CLEANUP_WAIT, |
| 329 | }; |
| 330 | |
Michael Chan | 4351477 | 2009-06-08 18:14:41 -0700 | [diff] [blame] | 331 | /* |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 332 | * Common error codes |
| 333 | */ |
| 334 | enum iscsi_err { |
| 335 | ISCSI_OK = 0, |
| 336 | |
| 337 | ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1, |
| 338 | ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2, |
| 339 | ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3, |
| 340 | ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4, |
| 341 | ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5, |
| 342 | ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6, |
| 343 | ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7, |
| 344 | ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8, |
| 345 | ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9, |
| 346 | ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10, |
| 347 | ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11, |
| 348 | ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12, |
| 349 | ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13, |
| 350 | ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14, |
| 351 | ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, |
Mike Christie | 7996a77 | 2006-04-06 21:13:41 -0500 | [diff] [blame] | 352 | ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16, |
| 353 | ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, |
Mike Christie | e5bd7b5 | 2008-09-24 11:46:10 -0500 | [diff] [blame] | 354 | ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, |
Mike Christie | 6f481e3 | 2008-09-24 11:46:13 -0500 | [diff] [blame] | 355 | ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, |
Mike Christie | d1af8a3 | 2009-08-20 15:11:02 -0500 | [diff] [blame] | 356 | ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, |
Mike Christie | df4da5c | 2010-12-31 02:22:18 -0600 | [diff] [blame] | 357 | ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
| 360 | /* |
| 361 | * iSCSI Parameters (RFC3720) |
| 362 | */ |
| 363 | enum iscsi_param { |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 364 | /* passed in using netlink set param */ |
| 365 | ISCSI_PARAM_MAX_RECV_DLENGTH, |
| 366 | ISCSI_PARAM_MAX_XMIT_DLENGTH, |
| 367 | ISCSI_PARAM_HDRDGST_EN, |
| 368 | ISCSI_PARAM_DATADGST_EN, |
| 369 | ISCSI_PARAM_INITIAL_R2T_EN, |
| 370 | ISCSI_PARAM_MAX_R2T, |
| 371 | ISCSI_PARAM_IMM_DATA_EN, |
| 372 | ISCSI_PARAM_FIRST_BURST, |
| 373 | ISCSI_PARAM_MAX_BURST, |
| 374 | ISCSI_PARAM_PDU_INORDER_EN, |
| 375 | ISCSI_PARAM_DATASEQ_INORDER_EN, |
| 376 | ISCSI_PARAM_ERL, |
| 377 | ISCSI_PARAM_IFMARKER_EN, |
| 378 | ISCSI_PARAM_OFMARKER_EN, |
Mike Christie | 8d2860b | 2006-05-02 19:46:47 -0500 | [diff] [blame] | 379 | ISCSI_PARAM_EXP_STATSN, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 380 | ISCSI_PARAM_TARGET_NAME, |
| 381 | ISCSI_PARAM_TPGT, |
| 382 | ISCSI_PARAM_PERSISTENT_ADDRESS, |
| 383 | ISCSI_PARAM_PERSISTENT_PORT, |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 384 | ISCSI_PARAM_SESS_RECOVERY_TMO, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 385 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 386 | /* passed in through bind conn using transport_fd */ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 387 | ISCSI_PARAM_CONN_PORT, |
| 388 | ISCSI_PARAM_CONN_ADDRESS, |
| 389 | |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 390 | ISCSI_PARAM_USERNAME, |
| 391 | ISCSI_PARAM_USERNAME_IN, |
| 392 | ISCSI_PARAM_PASSWORD, |
| 393 | ISCSI_PARAM_PASSWORD_IN, |
| 394 | |
Mike Christie | 843c0a8 | 2007-12-13 12:43:20 -0600 | [diff] [blame] | 395 | ISCSI_PARAM_FAST_ABORT, |
Mike Christie | f6d5180 | 2007-12-13 12:43:30 -0600 | [diff] [blame] | 396 | ISCSI_PARAM_ABORT_TMO, |
| 397 | ISCSI_PARAM_LU_RESET_TMO, |
| 398 | ISCSI_PARAM_HOST_RESET_TMO, |
| 399 | |
| 400 | ISCSI_PARAM_PING_TMO, |
| 401 | ISCSI_PARAM_RECV_TMO, |
Mike Christie | 88dfd34 | 2008-05-21 15:54:16 -0500 | [diff] [blame] | 402 | |
| 403 | ISCSI_PARAM_IFACE_NAME, |
| 404 | ISCSI_PARAM_ISID, |
| 405 | ISCSI_PARAM_INITIATOR_NAME, |
Mike Christie | 3fe5ae8 | 2009-11-11 16:34:33 -0600 | [diff] [blame] | 406 | |
| 407 | ISCSI_PARAM_TGT_RESET_TMO, |
Vikas Chaudhary | 3b2bef1 | 2010-07-10 14:51:30 +0530 | [diff] [blame] | 408 | ISCSI_PARAM_TARGET_ALIAS, |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 409 | /* must always be last */ |
| 410 | ISCSI_PARAM_MAX, |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 411 | }; |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 412 | |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 413 | /* iSCSI HBA params */ |
| 414 | enum iscsi_host_param { |
| 415 | ISCSI_HOST_PARAM_HWADDRESS, |
Mike Christie | 8ad5781 | 2007-05-30 12:57:13 -0500 | [diff] [blame] | 416 | ISCSI_HOST_PARAM_INITIATOR_NAME, |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 417 | ISCSI_HOST_PARAM_NETDEV_NAME, |
Mike Christie | 2223696 | 2007-05-30 12:57:24 -0500 | [diff] [blame] | 418 | ISCSI_HOST_PARAM_IPADDRESS, |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 419 | ISCSI_HOST_PARAM_MAX, |
| 420 | }; |
| 421 | |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 422 | #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) |
| 423 | #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 424 | |
| 425 | /* |
| 426 | * These flags presents iSCSI Data-Path capabilities. |
| 427 | */ |
| 428 | #define CAP_RECOVERY_L0 0x1 |
| 429 | #define CAP_RECOVERY_L1 0x2 |
| 430 | #define CAP_RECOVERY_L2 0x4 |
| 431 | #define CAP_MULTI_R2T 0x8 |
| 432 | #define CAP_HDRDGST 0x10 |
| 433 | #define CAP_DATADGST 0x20 |
| 434 | #define CAP_MULTI_CONN 0x40 |
| 435 | #define CAP_TEXT_NEGO 0x80 |
| 436 | #define CAP_MARKERS 0x100 |
Mike Christie | 0ab823d | 2007-05-30 12:57:22 -0500 | [diff] [blame] | 437 | #define CAP_FW_DB 0x200 |
Mike Christie | 63c62f1 | 2008-12-02 00:32:04 -0600 | [diff] [blame] | 438 | #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */ |
| 439 | #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */ |
| 440 | #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */ |
Mike Christie | 6df19a7 | 2008-12-02 00:32:16 -0600 | [diff] [blame] | 441 | #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal, |
| 442 | and verification */ |
Manish Rangankar | 17fa575 | 2011-07-25 13:48:52 -0500 | [diff] [blame] | 443 | #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */ |
Alex Aizman | 39e8479 | 2005-08-04 19:31:00 -0700 | [diff] [blame] | 444 | |
| 445 | /* |
| 446 | * These flags describes reason of stop_conn() call |
| 447 | */ |
| 448 | #define STOP_CONN_TERM 0x1 |
| 449 | #define STOP_CONN_SUSPEND 0x2 |
| 450 | #define STOP_CONN_RECOVER 0x3 |
| 451 | |
| 452 | #define ISCSI_STATS_CUSTOM_MAX 32 |
| 453 | #define ISCSI_STATS_CUSTOM_DESC_MAX 64 |
| 454 | struct iscsi_stats_custom { |
| 455 | char desc[ISCSI_STATS_CUSTOM_DESC_MAX]; |
| 456 | uint64_t value; |
| 457 | }; |
| 458 | |
| 459 | /* |
| 460 | * struct iscsi_stats - iSCSI Statistics (iSCSI MIB) |
| 461 | * |
| 462 | * Note: this structure contains counters collected on per-connection basis. |
| 463 | */ |
| 464 | struct iscsi_stats { |
| 465 | /* octets */ |
| 466 | uint64_t txdata_octets; |
| 467 | uint64_t rxdata_octets; |
| 468 | |
| 469 | /* xmit pdus */ |
| 470 | uint32_t noptx_pdus; |
| 471 | uint32_t scsicmd_pdus; |
| 472 | uint32_t tmfcmd_pdus; |
| 473 | uint32_t login_pdus; |
| 474 | uint32_t text_pdus; |
| 475 | uint32_t dataout_pdus; |
| 476 | uint32_t logout_pdus; |
| 477 | uint32_t snack_pdus; |
| 478 | |
| 479 | /* recv pdus */ |
| 480 | uint32_t noprx_pdus; |
| 481 | uint32_t scsirsp_pdus; |
| 482 | uint32_t tmfrsp_pdus; |
| 483 | uint32_t textrsp_pdus; |
| 484 | uint32_t datain_pdus; |
| 485 | uint32_t logoutrsp_pdus; |
| 486 | uint32_t r2t_pdus; |
| 487 | uint32_t async_pdus; |
| 488 | uint32_t rjt_pdus; |
| 489 | |
| 490 | /* errors */ |
| 491 | uint32_t digest_err; |
| 492 | uint32_t timeout_err; |
| 493 | |
| 494 | /* |
| 495 | * iSCSI Custom Statistics support, i.e. Transport could |
| 496 | * extend existing MIB statistics with its own specific statistics |
| 497 | * up to ISCSI_STATS_CUSTOM_MAX |
| 498 | */ |
| 499 | uint32_t custom_length; |
| 500 | struct iscsi_stats_custom custom[0] |
| 501 | __attribute__ ((aligned (sizeof(uint64_t)))); |
| 502 | }; |
| 503 | |
| 504 | #endif |