1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc) 4 * 5 * Copyright (C) 2005 Dmitry Yusupov 6 * Copyright (C) 2005 Alex Aizman 7 * maintained by open-iscsi@googlegroups.com 8 */ 9 10 #ifndef ISCSI_IF_H 11 #define ISCSI_IF_H 12 13 #include <scsi/iscsi_proto.h> 14 #include <linux/in.h> 15 #include <linux/in6.h> 16 17 #define ISCSI_NL_GRP_ISCSID 1 18 #define ISCSI_NL_GRP_UIP 2 19 20 #define UEVENT_BASE 10 21 #define KEVENT_BASE 100 22 #define ISCSI_ERR_BASE 1000 23 24 enum iscsi_uevent_e { 25 ISCSI_UEVENT_UNKNOWN = 0, 26 27 /* down events */ 28 ISCSI_UEVENT_CREATE_SESSION = UEVENT_BASE + 1, 29 ISCSI_UEVENT_DESTROY_SESSION = UEVENT_BASE + 2, 30 ISCSI_UEVENT_CREATE_CONN = UEVENT_BASE + 3, 31 ISCSI_UEVENT_DESTROY_CONN = UEVENT_BASE + 4, 32 ISCSI_UEVENT_BIND_CONN = UEVENT_BASE + 5, 33 ISCSI_UEVENT_SET_PARAM = UEVENT_BASE + 6, 34 ISCSI_UEVENT_START_CONN = UEVENT_BASE + 7, 35 ISCSI_UEVENT_STOP_CONN = UEVENT_BASE + 8, 36 ISCSI_UEVENT_SEND_PDU = UEVENT_BASE + 9, 37 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10, 38 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11, 39 40 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12, 41 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13, 42 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14, 43 44 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, 45 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16, 46 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17, 47 ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18, 48 ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST = UEVENT_BASE + 19, 49 50 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20, 51 ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21, 52 ISCSI_UEVENT_PING = UEVENT_BASE + 22, 53 ISCSI_UEVENT_GET_CHAP = UEVENT_BASE + 23, 54 ISCSI_UEVENT_DELETE_CHAP = UEVENT_BASE + 24, 55 ISCSI_UEVENT_SET_FLASHNODE_PARAMS = UEVENT_BASE + 25, 56 ISCSI_UEVENT_NEW_FLASHNODE = UEVENT_BASE + 26, 57 ISCSI_UEVENT_DEL_FLASHNODE = UEVENT_BASE + 27, 58 ISCSI_UEVENT_LOGIN_FLASHNODE = UEVENT_BASE + 28, 59 ISCSI_UEVENT_LOGOUT_FLASHNODE = UEVENT_BASE + 29, 60 ISCSI_UEVENT_LOGOUT_FLASHNODE_SID = UEVENT_BASE + 30, 61 ISCSI_UEVENT_SET_CHAP = UEVENT_BASE + 31, 62 ISCSI_UEVENT_GET_HOST_STATS = UEVENT_BASE + 32, 63 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, 68 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4, 69 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5, 70 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6, 71 72 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7, 73 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8, 74 ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9, 75 ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10, 76 ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11, 77 }; 78 79 enum iscsi_tgt_dscvr { 80 ISCSI_TGT_DSCVR_SEND_TARGETS = 1, 81 ISCSI_TGT_DSCVR_ISNS = 2, 82 ISCSI_TGT_DSCVR_SLP = 3, 83 }; 84 85 enum iscsi_host_event_code { 86 ISCSI_EVENT_LINKUP = 1, 87 ISCSI_EVENT_LINKDOWN, 88 /* must always be last */ 89 ISCSI_EVENT_MAX, 90 }; 91 92 struct iscsi_uevent { 93 uint32_t type; /* k/u events type */ 94 uint32_t iferror; /* carries interface or resource errors */ 95 uint64_t transport_handle; 96 97 union { 98 /* messages u -> k */ 99 struct msg_create_session { 100 uint32_t initial_cmdsn; 101 uint16_t cmds_max; 102 uint16_t queue_depth; 103 } c_session; 104 struct msg_create_bound_session { 105 uint64_t ep_handle; 106 uint32_t initial_cmdsn; 107 uint16_t cmds_max; 108 uint16_t queue_depth; 109 } c_bound_session; 110 struct msg_destroy_session { 111 uint32_t sid; 112 } d_session; 113 struct msg_create_conn { 114 uint32_t sid; 115 uint32_t cid; 116 } c_conn; 117 struct msg_bind_conn { 118 uint32_t sid; 119 uint32_t cid; 120 uint64_t transport_eph; 121 uint32_t is_leading; 122 } b_conn; 123 struct msg_destroy_conn { 124 uint32_t sid; 125 uint32_t cid; 126 } d_conn; 127 struct msg_send_pdu { 128 uint32_t sid; 129 uint32_t cid; 130 uint32_t hdr_size; 131 uint32_t data_size; 132 } send_pdu; 133 struct msg_set_param { 134 uint32_t sid; 135 uint32_t cid; 136 uint32_t param; /* enum iscsi_param */ 137 uint32_t len; 138 } set_param; 139 struct msg_start_conn { 140 uint32_t sid; 141 uint32_t cid; 142 } start_conn; 143 struct msg_stop_conn { 144 uint32_t sid; 145 uint32_t cid; 146 uint64_t conn_handle; 147 uint32_t flag; 148 } stop_conn; 149 struct msg_get_stats { 150 uint32_t sid; 151 uint32_t cid; 152 } get_stats; 153 struct msg_transport_connect { 154 uint32_t non_blocking; 155 } ep_connect; 156 struct msg_transport_connect_through_host { 157 uint32_t host_no; 158 uint32_t non_blocking; 159 } ep_connect_through_host; 160 struct msg_transport_poll { 161 uint64_t ep_handle; 162 uint32_t timeout_ms; 163 } ep_poll; 164 struct msg_transport_disconnect { 165 uint64_t ep_handle; 166 } ep_disconnect; 167 struct msg_tgt_dscvr { 168 enum iscsi_tgt_dscvr type; 169 uint32_t host_no; 170 /* 171 * enable = 1 to establish a new connection 172 * with the server. enable = 0 to disconnect 173 * from the server. Used primarily to switch 174 * from one iSNS server to another. 175 */ 176 uint32_t enable; 177 } tgt_dscvr; 178 struct msg_set_host_param { 179 uint32_t host_no; 180 uint32_t param; /* enum iscsi_host_param */ 181 uint32_t len; 182 } set_host_param; 183 struct msg_set_path { 184 uint32_t host_no; 185 } set_path; 186 struct msg_set_iface_params { 187 uint32_t host_no; 188 uint32_t count; 189 } set_iface_params; 190 struct msg_iscsi_ping { 191 uint32_t host_no; 192 uint32_t iface_num; 193 uint32_t iface_type; 194 uint32_t payload_size; 195 uint32_t pid; /* unique ping id associated 196 with each ping request */ 197 } iscsi_ping; 198 struct msg_get_chap { 199 uint32_t host_no; 200 uint32_t num_entries; /* number of CHAP entries 201 * on request, number of 202 * valid CHAP entries on 203 * response */ 204 uint16_t chap_tbl_idx; 205 } get_chap; 206 struct msg_delete_chap { 207 uint32_t host_no; 208 uint16_t chap_tbl_idx; 209 } delete_chap; 210 struct msg_set_flashnode_param { 211 uint32_t host_no; 212 uint32_t flashnode_idx; 213 uint32_t count; 214 } set_flashnode; 215 struct msg_new_flashnode { 216 uint32_t host_no; 217 uint32_t len; 218 } new_flashnode; 219 struct msg_del_flashnode { 220 uint32_t host_no; 221 uint32_t flashnode_idx; 222 } del_flashnode; 223 struct msg_login_flashnode { 224 uint32_t host_no; 225 uint32_t flashnode_idx; 226 } login_flashnode; 227 struct msg_logout_flashnode { 228 uint32_t host_no; 229 uint32_t flashnode_idx; 230 } logout_flashnode; 231 struct msg_logout_flashnode_sid { 232 uint32_t host_no; 233 uint32_t sid; 234 } logout_flashnode_sid; 235 struct msg_get_host_stats { 236 uint32_t host_no; 237 } get_host_stats; 238 } u; 239 union { 240 /* messages k -> u */ 241 int retcode; 242 struct msg_create_session_ret { 243 uint32_t sid; 244 uint32_t host_no; 245 } c_session_ret; 246 struct msg_create_conn_ret { 247 uint32_t sid; 248 uint32_t cid; 249 } c_conn_ret; 250 struct msg_unbind_session { 251 uint32_t sid; 252 uint32_t host_no; 253 } unbind_session; 254 struct msg_recv_req { 255 uint32_t sid; 256 uint32_t cid; 257 uint64_t recv_handle; 258 } recv_req; 259 struct msg_conn_login { 260 uint32_t sid; 261 uint32_t cid; 262 uint32_t state; /* enum iscsi_conn_state */ 263 } conn_login; 264 struct msg_conn_error { 265 uint32_t sid; 266 uint32_t cid; 267 uint32_t error; /* enum iscsi_err */ 268 } connerror; 269 struct msg_session_destroyed { 270 uint32_t host_no; 271 uint32_t sid; 272 } d_session; 273 struct msg_transport_connect_ret { 274 uint64_t handle; 275 } ep_connect_ret; 276 struct msg_req_path { 277 uint32_t host_no; 278 } req_path; 279 struct msg_notify_if_down { 280 uint32_t host_no; 281 } notify_if_down; 282 struct msg_host_event { 283 uint32_t host_no; 284 uint32_t data_size; 285 enum iscsi_host_event_code code; 286 } host_event; 287 struct msg_ping_comp { 288 uint32_t host_no; 289 uint32_t status; /* enum 290 * iscsi_ping_status_code */ 291 uint32_t pid; /* unique ping id associated 292 with each ping request */ 293 uint32_t data_size; 294 } ping_comp; 295 struct msg_new_flashnode_ret { 296 uint32_t flashnode_idx; 297 } new_flashnode_ret; 298 } r; 299 } __attribute__ ((aligned (sizeof(uint64_t)))); 300 301 enum iscsi_param_type { 302 ISCSI_PARAM, /* iscsi_param (session, conn, target, LU) */ 303 ISCSI_HOST_PARAM, /* iscsi_host_param */ 304 ISCSI_NET_PARAM, /* iscsi_net_param */ 305 ISCSI_FLASHNODE_PARAM, /* iscsi_flashnode_param */ 306 ISCSI_CHAP_PARAM, /* iscsi_chap_param */ 307 ISCSI_IFACE_PARAM, /* iscsi_iface_param */ 308 }; 309 310 /* structure for minimalist usecase */ 311 struct iscsi_param_info { 312 uint32_t len; /* Actual length of the param value */ 313 uint16_t param; /* iscsi param */ 314 uint8_t value[0]; /* length sized value follows */ 315 } __packed; 316 317 struct iscsi_iface_param_info { 318 uint32_t iface_num; /* iface number, 0 - n */ 319 uint32_t len; /* Actual length of the param */ 320 uint16_t param; /* iscsi param value */ 321 uint8_t iface_type; /* IPv4 or IPv6 */ 322 uint8_t param_type; /* iscsi_param_type */ 323 uint8_t value[0]; /* length sized value follows */ 324 } __packed; 325 326 /* 327 * To keep the struct iscsi_uevent size the same for userspace code 328 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and 329 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the 330 * struct iscsi_uevent in the NETLINK_ISCSI message. 331 */ 332 struct iscsi_path { 333 uint64_t handle; 334 uint8_t mac_addr[6]; 335 uint8_t mac_addr_old[6]; 336 uint32_t ip_addr_len; /* 4 or 16 */ 337 union { 338 struct in_addr v4_addr; 339 struct in6_addr v6_addr; 340 } src; 341 union { 342 struct in_addr v4_addr; 343 struct in6_addr v6_addr; 344 } dst; 345 uint16_t vlan_id; 346 uint16_t pmtu; 347 } __attribute__ ((aligned (sizeof(uint64_t)))); 348 349 /* iscsi iface enabled/disabled setting */ 350 #define ISCSI_IFACE_DISABLE 0x01 351 #define ISCSI_IFACE_ENABLE 0x02 352 353 /* ipv4 bootproto */ 354 #define ISCSI_BOOTPROTO_STATIC 0x01 355 #define ISCSI_BOOTPROTO_DHCP 0x02 356 357 /* ipv6 addr autoconfig type */ 358 #define ISCSI_IPV6_AUTOCFG_DISABLE 0x01 359 #define ISCSI_IPV6_AUTOCFG_ND_ENABLE 0x02 360 #define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE 0x03 361 362 /* ipv6 link local addr type */ 363 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE 0x01 364 #define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE 0x02 365 366 /* ipv6 router addr type */ 367 #define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE 0x01 368 #define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE 0x02 369 370 #define ISCSI_IFACE_TYPE_IPV4 0x01 371 #define ISCSI_IFACE_TYPE_IPV6 0x02 372 373 #define ISCSI_MAX_VLAN_ID 4095 374 #define ISCSI_MAX_VLAN_PRIORITY 7 375 376 /* iscsi vlan enable/disabled setting */ 377 #define ISCSI_VLAN_DISABLE 0x01 378 #define ISCSI_VLAN_ENABLE 0x02 379 380 /* iscsi generic enable/disabled setting for various features */ 381 #define ISCSI_NET_PARAM_DISABLE 0x01 382 #define ISCSI_NET_PARAM_ENABLE 0x02 383 384 /* iSCSI network params */ 385 enum iscsi_net_param { 386 ISCSI_NET_PARAM_IPV4_ADDR = 1, 387 ISCSI_NET_PARAM_IPV4_SUBNET, 388 ISCSI_NET_PARAM_IPV4_GW, 389 ISCSI_NET_PARAM_IPV4_BOOTPROTO, 390 ISCSI_NET_PARAM_MAC, 391 ISCSI_NET_PARAM_IPV6_LINKLOCAL, 392 ISCSI_NET_PARAM_IPV6_ADDR, 393 ISCSI_NET_PARAM_IPV6_ROUTER, 394 ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG, 395 ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG, 396 ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG, 397 ISCSI_NET_PARAM_IFACE_ENABLE, 398 ISCSI_NET_PARAM_VLAN_ID, 399 ISCSI_NET_PARAM_VLAN_PRIORITY, 400 ISCSI_NET_PARAM_VLAN_ENABLED, 401 ISCSI_NET_PARAM_VLAN_TAG, 402 ISCSI_NET_PARAM_IFACE_TYPE, 403 ISCSI_NET_PARAM_IFACE_NAME, 404 ISCSI_NET_PARAM_MTU, 405 ISCSI_NET_PARAM_PORT, 406 ISCSI_NET_PARAM_IPADDR_STATE, 407 ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE, 408 ISCSI_NET_PARAM_IPV6_ROUTER_STATE, 409 ISCSI_NET_PARAM_DELAYED_ACK_EN, 410 ISCSI_NET_PARAM_TCP_NAGLE_DISABLE, 411 ISCSI_NET_PARAM_TCP_WSF_DISABLE, 412 ISCSI_NET_PARAM_TCP_WSF, 413 ISCSI_NET_PARAM_TCP_TIMER_SCALE, 414 ISCSI_NET_PARAM_TCP_TIMESTAMP_EN, 415 ISCSI_NET_PARAM_CACHE_ID, 416 ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN, 417 ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN, 418 ISCSI_NET_PARAM_IPV4_TOS_EN, 419 ISCSI_NET_PARAM_IPV4_TOS, 420 ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN, 421 ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN, 422 ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID, 423 ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN, 424 ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN, 425 ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID, 426 ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN, 427 ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE, 428 ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN, 429 ISCSI_NET_PARAM_IPV4_TTL, 430 ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN, 431 ISCSI_NET_PARAM_IPV6_MLD_EN, 432 ISCSI_NET_PARAM_IPV6_FLOW_LABEL, 433 ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS, 434 ISCSI_NET_PARAM_IPV6_HOP_LIMIT, 435 ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO, 436 ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME, 437 ISCSI_NET_PARAM_IPV6_ND_STALE_TMO, 438 ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT, 439 ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU, 440 ISCSI_NET_PARAM_REDIRECT_EN, 441 }; 442 443 enum iscsi_ipaddress_state { 444 ISCSI_IPDDRESS_STATE_UNCONFIGURED, 445 ISCSI_IPDDRESS_STATE_ACQUIRING, 446 ISCSI_IPDDRESS_STATE_TENTATIVE, 447 ISCSI_IPDDRESS_STATE_VALID, 448 ISCSI_IPDDRESS_STATE_DISABLING, 449 ISCSI_IPDDRESS_STATE_INVALID, 450 ISCSI_IPDDRESS_STATE_DEPRECATED, 451 }; 452 453 enum iscsi_router_state { 454 ISCSI_ROUTER_STATE_UNKNOWN, 455 ISCSI_ROUTER_STATE_ADVERTISED, 456 ISCSI_ROUTER_STATE_MANUAL, 457 ISCSI_ROUTER_STATE_STALE, 458 }; 459 460 /* iSCSI specific settings params for iface */ 461 enum iscsi_iface_param { 462 ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO, 463 ISCSI_IFACE_PARAM_HDRDGST_EN, 464 ISCSI_IFACE_PARAM_DATADGST_EN, 465 ISCSI_IFACE_PARAM_IMM_DATA_EN, 466 ISCSI_IFACE_PARAM_INITIAL_R2T_EN, 467 ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN, 468 ISCSI_IFACE_PARAM_PDU_INORDER_EN, 469 ISCSI_IFACE_PARAM_ERL, 470 ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH, 471 ISCSI_IFACE_PARAM_FIRST_BURST, 472 ISCSI_IFACE_PARAM_MAX_R2T, 473 ISCSI_IFACE_PARAM_MAX_BURST, 474 ISCSI_IFACE_PARAM_CHAP_AUTH_EN, 475 ISCSI_IFACE_PARAM_BIDI_CHAP_EN, 476 ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL, 477 ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN, 478 ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN, 479 ISCSI_IFACE_PARAM_INITIATOR_NAME, 480 }; 481 482 enum iscsi_conn_state { 483 ISCSI_CONN_STATE_FREE, 484 ISCSI_CONN_STATE_XPT_WAIT, 485 ISCSI_CONN_STATE_IN_LOGIN, 486 ISCSI_CONN_STATE_LOGGED_IN, 487 ISCSI_CONN_STATE_IN_LOGOUT, 488 ISCSI_CONN_STATE_LOGOUT_REQUESTED, 489 ISCSI_CONN_STATE_CLEANUP_WAIT, 490 }; 491 492 /* 493 * Common error codes 494 */ 495 enum iscsi_err { 496 ISCSI_OK = 0, 497 498 ISCSI_ERR_DATASN = ISCSI_ERR_BASE + 1, 499 ISCSI_ERR_DATA_OFFSET = ISCSI_ERR_BASE + 2, 500 ISCSI_ERR_MAX_CMDSN = ISCSI_ERR_BASE + 3, 501 ISCSI_ERR_EXP_CMDSN = ISCSI_ERR_BASE + 4, 502 ISCSI_ERR_BAD_OPCODE = ISCSI_ERR_BASE + 5, 503 ISCSI_ERR_DATALEN = ISCSI_ERR_BASE + 6, 504 ISCSI_ERR_AHSLEN = ISCSI_ERR_BASE + 7, 505 ISCSI_ERR_PROTO = ISCSI_ERR_BASE + 8, 506 ISCSI_ERR_LUN = ISCSI_ERR_BASE + 9, 507 ISCSI_ERR_BAD_ITT = ISCSI_ERR_BASE + 10, 508 ISCSI_ERR_CONN_FAILED = ISCSI_ERR_BASE + 11, 509 ISCSI_ERR_R2TSN = ISCSI_ERR_BASE + 12, 510 ISCSI_ERR_SESSION_FAILED = ISCSI_ERR_BASE + 13, 511 ISCSI_ERR_HDR_DGST = ISCSI_ERR_BASE + 14, 512 ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, 513 ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16, 514 ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, 515 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, 516 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, 517 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, 518 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21, 519 ISCSI_ERR_NOP_TIMEDOUT = ISCSI_ERR_BASE + 22, 520 }; 521 522 /* 523 * iSCSI Parameters (RFC3720) 524 */ 525 enum iscsi_param { 526 /* passed in using netlink set param */ 527 ISCSI_PARAM_MAX_RECV_DLENGTH, 528 ISCSI_PARAM_MAX_XMIT_DLENGTH, 529 ISCSI_PARAM_HDRDGST_EN, 530 ISCSI_PARAM_DATADGST_EN, 531 ISCSI_PARAM_INITIAL_R2T_EN, 532 ISCSI_PARAM_MAX_R2T, 533 ISCSI_PARAM_IMM_DATA_EN, 534 ISCSI_PARAM_FIRST_BURST, 535 ISCSI_PARAM_MAX_BURST, 536 ISCSI_PARAM_PDU_INORDER_EN, 537 ISCSI_PARAM_DATASEQ_INORDER_EN, 538 ISCSI_PARAM_ERL, 539 ISCSI_PARAM_IFMARKER_EN, 540 ISCSI_PARAM_OFMARKER_EN, 541 ISCSI_PARAM_EXP_STATSN, 542 ISCSI_PARAM_TARGET_NAME, 543 ISCSI_PARAM_TPGT, 544 ISCSI_PARAM_PERSISTENT_ADDRESS, 545 ISCSI_PARAM_PERSISTENT_PORT, 546 ISCSI_PARAM_SESS_RECOVERY_TMO, 547 548 /* passed in through bind conn using transport_fd */ 549 ISCSI_PARAM_CONN_PORT, 550 ISCSI_PARAM_CONN_ADDRESS, 551 552 ISCSI_PARAM_USERNAME, 553 ISCSI_PARAM_USERNAME_IN, 554 ISCSI_PARAM_PASSWORD, 555 ISCSI_PARAM_PASSWORD_IN, 556 557 ISCSI_PARAM_FAST_ABORT, 558 ISCSI_PARAM_ABORT_TMO, 559 ISCSI_PARAM_LU_RESET_TMO, 560 ISCSI_PARAM_HOST_RESET_TMO, 561 562 ISCSI_PARAM_PING_TMO, 563 ISCSI_PARAM_RECV_TMO, 564 565 ISCSI_PARAM_IFACE_NAME, 566 ISCSI_PARAM_ISID, 567 ISCSI_PARAM_INITIATOR_NAME, 568 569 ISCSI_PARAM_TGT_RESET_TMO, 570 ISCSI_PARAM_TARGET_ALIAS, 571 572 ISCSI_PARAM_CHAP_IN_IDX, 573 ISCSI_PARAM_CHAP_OUT_IDX, 574 575 ISCSI_PARAM_BOOT_ROOT, 576 ISCSI_PARAM_BOOT_NIC, 577 ISCSI_PARAM_BOOT_TARGET, 578 579 ISCSI_PARAM_AUTO_SND_TGT_DISABLE, 580 ISCSI_PARAM_DISCOVERY_SESS, 581 ISCSI_PARAM_PORTAL_TYPE, 582 ISCSI_PARAM_CHAP_AUTH_EN, 583 ISCSI_PARAM_DISCOVERY_LOGOUT_EN, 584 ISCSI_PARAM_BIDI_CHAP_EN, 585 ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL, 586 587 ISCSI_PARAM_DEF_TIME2WAIT, 588 ISCSI_PARAM_DEF_TIME2RETAIN, 589 ISCSI_PARAM_MAX_SEGMENT_SIZE, 590 ISCSI_PARAM_STATSN, 591 ISCSI_PARAM_KEEPALIVE_TMO, 592 ISCSI_PARAM_LOCAL_PORT, 593 ISCSI_PARAM_TSID, 594 ISCSI_PARAM_DEF_TASKMGMT_TMO, 595 596 ISCSI_PARAM_TCP_TIMESTAMP_STAT, 597 ISCSI_PARAM_TCP_WSF_DISABLE, 598 ISCSI_PARAM_TCP_NAGLE_DISABLE, 599 ISCSI_PARAM_TCP_TIMER_SCALE, 600 ISCSI_PARAM_TCP_TIMESTAMP_EN, 601 ISCSI_PARAM_TCP_XMIT_WSF, 602 ISCSI_PARAM_TCP_RECV_WSF, 603 ISCSI_PARAM_IP_FRAGMENT_DISABLE, 604 ISCSI_PARAM_IPV4_TOS, 605 ISCSI_PARAM_IPV6_TC, 606 ISCSI_PARAM_IPV6_FLOW_LABEL, 607 ISCSI_PARAM_IS_FW_ASSIGNED_IPV6, 608 609 ISCSI_PARAM_DISCOVERY_PARENT_IDX, 610 ISCSI_PARAM_DISCOVERY_PARENT_TYPE, 611 ISCSI_PARAM_LOCAL_IPADDR, 612 /* must always be last */ 613 ISCSI_PARAM_MAX, 614 }; 615 616 /* iSCSI HBA params */ 617 enum iscsi_host_param { 618 ISCSI_HOST_PARAM_HWADDRESS, 619 ISCSI_HOST_PARAM_INITIATOR_NAME, 620 ISCSI_HOST_PARAM_NETDEV_NAME, 621 ISCSI_HOST_PARAM_IPADDRESS, 622 ISCSI_HOST_PARAM_PORT_STATE, 623 ISCSI_HOST_PARAM_PORT_SPEED, 624 ISCSI_HOST_PARAM_MAX, 625 }; 626 627 /* portal type */ 628 #define PORTAL_TYPE_IPV4 "ipv4" 629 #define PORTAL_TYPE_IPV6 "ipv6" 630 631 /* iSCSI Flash Target params */ 632 enum iscsi_flashnode_param { 633 ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6, 634 ISCSI_FLASHNODE_PORTAL_TYPE, 635 ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE, 636 ISCSI_FLASHNODE_DISCOVERY_SESS, 637 ISCSI_FLASHNODE_ENTRY_EN, 638 ISCSI_FLASHNODE_HDR_DGST_EN, 639 ISCSI_FLASHNODE_DATA_DGST_EN, 640 ISCSI_FLASHNODE_IMM_DATA_EN, 641 ISCSI_FLASHNODE_INITIAL_R2T_EN, 642 ISCSI_FLASHNODE_DATASEQ_INORDER, 643 ISCSI_FLASHNODE_PDU_INORDER, 644 ISCSI_FLASHNODE_CHAP_AUTH_EN, 645 ISCSI_FLASHNODE_SNACK_REQ_EN, 646 ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN, 647 ISCSI_FLASHNODE_BIDI_CHAP_EN, 648 /* make authentication for discovery sessions optional */ 649 ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL, 650 ISCSI_FLASHNODE_ERL, 651 ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT, 652 ISCSI_FLASHNODE_TCP_NAGLE_DISABLE, 653 ISCSI_FLASHNODE_TCP_WSF_DISABLE, 654 ISCSI_FLASHNODE_TCP_TIMER_SCALE, 655 ISCSI_FLASHNODE_TCP_TIMESTAMP_EN, 656 ISCSI_FLASHNODE_IP_FRAG_DISABLE, 657 ISCSI_FLASHNODE_MAX_RECV_DLENGTH, 658 ISCSI_FLASHNODE_MAX_XMIT_DLENGTH, 659 ISCSI_FLASHNODE_FIRST_BURST, 660 ISCSI_FLASHNODE_DEF_TIME2WAIT, 661 ISCSI_FLASHNODE_DEF_TIME2RETAIN, 662 ISCSI_FLASHNODE_MAX_R2T, 663 ISCSI_FLASHNODE_KEEPALIVE_TMO, 664 ISCSI_FLASHNODE_ISID, 665 ISCSI_FLASHNODE_TSID, 666 ISCSI_FLASHNODE_PORT, 667 ISCSI_FLASHNODE_MAX_BURST, 668 ISCSI_FLASHNODE_DEF_TASKMGMT_TMO, 669 ISCSI_FLASHNODE_IPADDR, 670 ISCSI_FLASHNODE_ALIAS, 671 ISCSI_FLASHNODE_REDIRECT_IPADDR, 672 ISCSI_FLASHNODE_MAX_SEGMENT_SIZE, 673 ISCSI_FLASHNODE_LOCAL_PORT, 674 ISCSI_FLASHNODE_IPV4_TOS, 675 ISCSI_FLASHNODE_IPV6_TC, 676 ISCSI_FLASHNODE_IPV6_FLOW_LABEL, 677 ISCSI_FLASHNODE_NAME, 678 ISCSI_FLASHNODE_TPGT, 679 ISCSI_FLASHNODE_LINK_LOCAL_IPV6, 680 ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX, 681 ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE, 682 ISCSI_FLASHNODE_TCP_XMIT_WSF, 683 ISCSI_FLASHNODE_TCP_RECV_WSF, 684 ISCSI_FLASHNODE_CHAP_IN_IDX, 685 ISCSI_FLASHNODE_CHAP_OUT_IDX, 686 ISCSI_FLASHNODE_USERNAME, 687 ISCSI_FLASHNODE_USERNAME_IN, 688 ISCSI_FLASHNODE_PASSWORD, 689 ISCSI_FLASHNODE_PASSWORD_IN, 690 ISCSI_FLASHNODE_STATSN, 691 ISCSI_FLASHNODE_EXP_STATSN, 692 ISCSI_FLASHNODE_IS_BOOT_TGT, 693 694 ISCSI_FLASHNODE_MAX, 695 }; 696 697 struct iscsi_flashnode_param_info { 698 uint32_t len; /* Actual length of the param */ 699 uint16_t param; /* iscsi param value */ 700 uint8_t value[0]; /* length sized value follows */ 701 } __packed; 702 703 enum iscsi_discovery_parent_type { 704 ISCSI_DISC_PARENT_UNKNOWN = 0x1, 705 ISCSI_DISC_PARENT_SENDTGT = 0x2, 706 ISCSI_DISC_PARENT_ISNS = 0x3, 707 }; 708 709 /* iSCSI port Speed */ 710 enum iscsi_port_speed { 711 ISCSI_PORT_SPEED_UNKNOWN = 0x1, 712 ISCSI_PORT_SPEED_10MBPS = 0x2, 713 ISCSI_PORT_SPEED_100MBPS = 0x4, 714 ISCSI_PORT_SPEED_1GBPS = 0x8, 715 ISCSI_PORT_SPEED_10GBPS = 0x10, 716 ISCSI_PORT_SPEED_25GBPS = 0x20, 717 ISCSI_PORT_SPEED_40GBPS = 0x40, 718 }; 719 720 /* iSCSI port state */ 721 enum iscsi_port_state { 722 ISCSI_PORT_STATE_DOWN = 0x1, 723 ISCSI_PORT_STATE_UP = 0x2, 724 }; 725 726 /* iSCSI PING status/error code */ 727 enum iscsi_ping_status_code { 728 ISCSI_PING_SUCCESS = 0, 729 ISCSI_PING_FW_DISABLED = 0x1, 730 ISCSI_PING_IPADDR_INVALID = 0x2, 731 ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID = 0x3, 732 ISCSI_PING_TIMEOUT = 0x4, 733 ISCSI_PING_INVALID_DEST_ADDR = 0x5, 734 ISCSI_PING_OVERSIZE_PACKET = 0x6, 735 ISCSI_PING_ICMP_ERROR = 0x7, 736 ISCSI_PING_MAX_REQ_EXCEEDED = 0x8, 737 ISCSI_PING_NO_ARP_RECEIVED = 0x9, 738 }; 739 740 #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) 741 #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) 742 743 /* 744 * These flags presents iSCSI Data-Path capabilities. 745 */ 746 #define CAP_RECOVERY_L0 0x1 747 #define CAP_RECOVERY_L1 0x2 748 #define CAP_RECOVERY_L2 0x4 749 #define CAP_MULTI_R2T 0x8 750 #define CAP_HDRDGST 0x10 751 #define CAP_DATADGST 0x20 752 #define CAP_MULTI_CONN 0x40 753 #define CAP_TEXT_NEGO 0x80 754 #define CAP_MARKERS 0x100 755 #define CAP_FW_DB 0x200 756 #define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */ 757 #define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */ 758 #define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */ 759 #define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal, 760 and verification */ 761 #define CAP_LOGIN_OFFLOAD 0x4000 /* offload session login */ 762 763 /* 764 * These flags describes reason of stop_conn() call 765 */ 766 #define STOP_CONN_TERM 0x1 767 #define STOP_CONN_SUSPEND 0x2 768 #define STOP_CONN_RECOVER 0x3 769 770 #define ISCSI_STATS_CUSTOM_MAX 32 771 #define ISCSI_STATS_CUSTOM_DESC_MAX 64 772 struct iscsi_stats_custom { 773 char desc[ISCSI_STATS_CUSTOM_DESC_MAX]; 774 uint64_t value; 775 }; 776 777 /* 778 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB) 779 * 780 * Note: this structure contains counters collected on per-connection basis. 781 */ 782 struct iscsi_stats { 783 /* octets */ 784 uint64_t txdata_octets; 785 uint64_t rxdata_octets; 786 787 /* xmit pdus */ 788 uint32_t noptx_pdus; 789 uint32_t scsicmd_pdus; 790 uint32_t tmfcmd_pdus; 791 uint32_t login_pdus; 792 uint32_t text_pdus; 793 uint32_t dataout_pdus; 794 uint32_t logout_pdus; 795 uint32_t snack_pdus; 796 797 /* recv pdus */ 798 uint32_t noprx_pdus; 799 uint32_t scsirsp_pdus; 800 uint32_t tmfrsp_pdus; 801 uint32_t textrsp_pdus; 802 uint32_t datain_pdus; 803 uint32_t logoutrsp_pdus; 804 uint32_t r2t_pdus; 805 uint32_t async_pdus; 806 uint32_t rjt_pdus; 807 808 /* errors */ 809 uint32_t digest_err; 810 uint32_t timeout_err; 811 812 /* 813 * iSCSI Custom Statistics support, i.e. Transport could 814 * extend existing MIB statistics with its own specific statistics 815 * up to ISCSI_STATS_CUSTOM_MAX 816 */ 817 uint32_t custom_length; 818 struct iscsi_stats_custom custom[0] 819 __attribute__ ((aligned (sizeof(uint64_t)))); 820 }; 821 822 enum chap_type_e { 823 CHAP_TYPE_OUT, 824 CHAP_TYPE_IN, 825 }; 826 827 enum iscsi_chap_param { 828 ISCSI_CHAP_PARAM_INDEX, 829 ISCSI_CHAP_PARAM_CHAP_TYPE, 830 ISCSI_CHAP_PARAM_USERNAME, 831 ISCSI_CHAP_PARAM_PASSWORD, 832 ISCSI_CHAP_PARAM_PASSWORD_LEN 833 }; 834 835 #define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256 836 #define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256 837 struct iscsi_chap_rec { 838 uint16_t chap_tbl_idx; 839 enum chap_type_e chap_type; 840 char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN]; 841 uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN]; 842 uint8_t password_length; 843 }; 844 845 #define ISCSI_HOST_STATS_CUSTOM_MAX 32 846 #define ISCSI_HOST_STATS_CUSTOM_DESC_MAX 64 847 struct iscsi_host_stats_custom { 848 char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX]; 849 uint64_t value; 850 }; 851 852 /* struct iscsi_offload_host_stats: Host statistics, 853 * Include statistics for MAC, IP, TCP & iSCSI. 854 */ 855 struct iscsi_offload_host_stats { 856 /* MAC */ 857 uint64_t mactx_frames; 858 uint64_t mactx_bytes; 859 uint64_t mactx_multicast_frames; 860 uint64_t mactx_broadcast_frames; 861 uint64_t mactx_pause_frames; 862 uint64_t mactx_control_frames; 863 uint64_t mactx_deferral; 864 uint64_t mactx_excess_deferral; 865 uint64_t mactx_late_collision; 866 uint64_t mactx_abort; 867 uint64_t mactx_single_collision; 868 uint64_t mactx_multiple_collision; 869 uint64_t mactx_collision; 870 uint64_t mactx_frames_dropped; 871 uint64_t mactx_jumbo_frames; 872 uint64_t macrx_frames; 873 uint64_t macrx_bytes; 874 uint64_t macrx_unknown_control_frames; 875 uint64_t macrx_pause_frames; 876 uint64_t macrx_control_frames; 877 uint64_t macrx_dribble; 878 uint64_t macrx_frame_length_error; 879 uint64_t macrx_jabber; 880 uint64_t macrx_carrier_sense_error; 881 uint64_t macrx_frame_discarded; 882 uint64_t macrx_frames_dropped; 883 uint64_t mac_crc_error; 884 uint64_t mac_encoding_error; 885 uint64_t macrx_length_error_large; 886 uint64_t macrx_length_error_small; 887 uint64_t macrx_multicast_frames; 888 uint64_t macrx_broadcast_frames; 889 /* IP */ 890 uint64_t iptx_packets; 891 uint64_t iptx_bytes; 892 uint64_t iptx_fragments; 893 uint64_t iprx_packets; 894 uint64_t iprx_bytes; 895 uint64_t iprx_fragments; 896 uint64_t ip_datagram_reassembly; 897 uint64_t ip_invalid_address_error; 898 uint64_t ip_error_packets; 899 uint64_t ip_fragrx_overlap; 900 uint64_t ip_fragrx_outoforder; 901 uint64_t ip_datagram_reassembly_timeout; 902 uint64_t ipv6tx_packets; 903 uint64_t ipv6tx_bytes; 904 uint64_t ipv6tx_fragments; 905 uint64_t ipv6rx_packets; 906 uint64_t ipv6rx_bytes; 907 uint64_t ipv6rx_fragments; 908 uint64_t ipv6_datagram_reassembly; 909 uint64_t ipv6_invalid_address_error; 910 uint64_t ipv6_error_packets; 911 uint64_t ipv6_fragrx_overlap; 912 uint64_t ipv6_fragrx_outoforder; 913 uint64_t ipv6_datagram_reassembly_timeout; 914 /* TCP */ 915 uint64_t tcptx_segments; 916 uint64_t tcptx_bytes; 917 uint64_t tcprx_segments; 918 uint64_t tcprx_byte; 919 uint64_t tcp_duplicate_ack_retx; 920 uint64_t tcp_retx_timer_expired; 921 uint64_t tcprx_duplicate_ack; 922 uint64_t tcprx_pure_ackr; 923 uint64_t tcptx_delayed_ack; 924 uint64_t tcptx_pure_ack; 925 uint64_t tcprx_segment_error; 926 uint64_t tcprx_segment_outoforder; 927 uint64_t tcprx_window_probe; 928 uint64_t tcprx_window_update; 929 uint64_t tcptx_window_probe_persist; 930 /* ECC */ 931 uint64_t ecc_error_correction; 932 /* iSCSI */ 933 uint64_t iscsi_pdu_tx; 934 uint64_t iscsi_data_bytes_tx; 935 uint64_t iscsi_pdu_rx; 936 uint64_t iscsi_data_bytes_rx; 937 uint64_t iscsi_io_completed; 938 uint64_t iscsi_unexpected_io_rx; 939 uint64_t iscsi_format_error; 940 uint64_t iscsi_hdr_digest_error; 941 uint64_t iscsi_data_digest_error; 942 uint64_t iscsi_sequence_error; 943 /* 944 * iSCSI Custom Host Statistics support, i.e. Transport could 945 * extend existing host statistics with its own specific statistics 946 * up to ISCSI_HOST_STATS_CUSTOM_MAX 947 */ 948 uint32_t custom_length; 949 struct iscsi_host_stats_custom custom[0] 950 __aligned(sizeof(uint64_t)); 951 }; 952 953 #endif 954