1 1.5 mlelstv /* $NetBSD: iscsi.h,v 1.5 2023/11/25 10:08:27 mlelstv Exp $ */ 2 1.1 agc 3 1.1 agc /*- 4 1.1 agc * Copyright (c) 2004,2006,2011 The NetBSD Foundation, Inc. 5 1.1 agc * All rights reserved. 6 1.1 agc * 7 1.1 agc * This code is derived from software contributed to The NetBSD Foundation 8 1.1 agc * by Wasabi Systems, Inc. 9 1.1 agc * 10 1.1 agc * Redistribution and use in source and binary forms, with or without 11 1.1 agc * modification, are permitted provided that the following conditions 12 1.1 agc * are met: 13 1.1 agc * 1. Redistributions of source code must retain the above copyright 14 1.1 agc * notice, this list of conditions and the following disclaimer. 15 1.1 agc * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 agc * notice, this list of conditions and the following disclaimer in the 17 1.1 agc * documentation and/or other materials provided with the distribution. 18 1.1 agc * 19 1.1 agc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 agc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 agc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 agc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 agc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 agc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 agc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 agc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 agc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 agc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 agc * POSSIBILITY OF SUCH DAMAGE. 30 1.1 agc */ 31 1.1 agc #ifndef _ISCSI_H 32 1.1 agc #define _ISCSI_H 33 1.1 agc 34 1.3 agc #define ISCSI_DEV_MAJOR 203 35 1.1 agc 36 1.1 agc #define ISCSI_STRING_LENGTH (223+1) 37 1.1 agc #define ISCSI_ADDRESS_LENGTH (255+1) 38 1.1 agc #define ISCSI_AUTH_OPTIONS 4 39 1.1 agc 40 1.1 agc typedef enum { 41 1.1 agc ISCSI_AUTH_None = 0, 42 1.1 agc ISCSI_AUTH_CHAP = 1, 43 1.1 agc ISCSI_AUTH_KRB5 = 2, 44 1.1 agc ISCSI_AUTH_SRP = 3 45 1.1 agc } iscsi_auth_types_t; 46 1.1 agc /* 47 1.1 agc ISCSI_AUTH_None 48 1.1 agc Indicates that no authentication is necessary. 49 1.1 agc ISCSI_AUTH_CHAP 50 1.1 agc Indicates CHAP authentication should be used. 51 1.1 agc ISCSI_AUTH_KRB5 52 1.1 agc Indicates Kerberos 5 authentication (fur future use). 53 1.1 agc ISCSI_AUTH_SRP 54 1.1 agc Indicates SRP authentication (for future use). 55 1.1 agc */ 56 1.1 agc 57 1.5 mlelstv typedef enum { 58 1.5 mlelstv ISCSI_CHAP_MD5 = 5, 59 1.5 mlelstv ISCSI_CHAP_SHA1 = 6, 60 1.5 mlelstv ISCSI_CHAP_SHA256 = 7, 61 1.5 mlelstv ISCSI_CHAP_SHA3_256 = 8 62 1.5 mlelstv } iscsi_chap_types_t; 63 1.5 mlelstv 64 1.1 agc typedef struct { 65 1.2 christos unsigned int mutual_auth:1; 66 1.2 christos unsigned int is_secure:1; 67 1.2 christos unsigned int auth_number:4; 68 1.1 agc iscsi_auth_types_t auth_type[ISCSI_AUTH_OPTIONS]; 69 1.1 agc } iscsi_auth_info_t; 70 1.1 agc 71 1.1 agc /* 72 1.1 agc mutual_auth 73 1.1 agc Indicates that authentication should be mutual, i.e. 74 1.1 agc the initiator should authenticate the target, and the target 75 1.1 agc should authenticate the initiator. If not specified, the target 76 1.1 agc will authenticate the initiator only. 77 1.1 agc is_secure 78 1.1 agc Indicates that the connection is secure. 79 1.1 agc auth_number 80 1.1 agc Indicates the number of elements in auth_type. 81 1.1 agc When 0, no authentication will be used. 82 1.1 agc auth_type 83 1.1 agc Contains up to ISCSI_AUTH_OPTIONS enumerator values of type 84 1.1 agc ISCSI_AUTH_TYPES that indicates the authentication method that 85 1.1 agc should be used to establish a login connection (none, CHAP, KRB5, 86 1.1 agc etc.), in order of priority. The first element is the most 87 1.1 agc preferred method, the last element the least preferred. 88 1.1 agc 89 1.1 agc */ 90 1.1 agc 91 1.1 agc typedef enum { 92 1.1 agc ISCSI_DIGEST_None = 0, 93 1.1 agc ISCSI_DIGEST_CRC32C = 1 94 1.1 agc } iscsi_digest_t; 95 1.1 agc 96 1.1 agc /* 97 1.1 agc ISCSI_DIGEST_None 98 1.1 agc Indicates that no CRC is to be generated. 99 1.1 agc ISCSI_DIGEST_CRC32C 100 1.1 agc Indicates the CRC32C digest should be used. 101 1.1 agc */ 102 1.1 agc 103 1.1 agc typedef enum { 104 1.1 agc ISCSI_LOGINTYPE_DISCOVERY = 0, 105 1.1 agc ISCSI_LOGINTYPE_NOMAP = 1, 106 1.1 agc ISCSI_LOGINTYPE_MAP = 2 107 1.1 agc } iscsi_login_session_type_t; 108 1.1 agc 109 1.1 agc /* 110 1.1 agc ISCSI_LOGINTYPE_DISCOVERY 111 1.1 agc Indicates that the login session is for discovery only. 112 1.1 agc Initiators use this type of session to send a SCSI SendTargets 113 1.1 agc command to an iSCSI target to request assistance in 114 1.1 agc discovering other targets accessible to the target that 115 1.1 agc receives the SendTargets command. 116 1.1 agc ISCSI_LOGINTYPE_NOMAP 117 1.1 agc This establishes a normal (full featured) session, but does 118 1.1 agc not report the target LUNs to the operating system as 119 1.1 agc available drives. Communication with the target is limited 120 1.1 agc to io-controls through the driver. 121 1.1 agc ISCSI_LOGINTYPE_MAP 122 1.1 agc Indicates that the login session is full featured, and reports 123 1.1 agc all target LUNs to the operating system to map as logical drives. 124 1.1 agc */ 125 1.1 agc 126 1.1 agc typedef struct { 127 1.1 agc uint8_t address[ISCSI_ADDRESS_LENGTH]; 128 1.1 agc uint16_t port; 129 1.1 agc uint16_t group_tag; 130 1.1 agc } iscsi_portal_address_t; 131 1.1 agc 132 1.1 agc /* 133 1.1 agc address 134 1.1 agc IP address of the target (V4 dotted quad or V6 hex). 135 1.1 agc port 136 1.1 agc IP port number. 137 1.1 agc group_tag 138 1.1 agc Target portal group tag (0 if unknown). 139 1.1 agc */ 140 1.1 agc 141 1.1 agc 142 1.1 agc /* ------------------------- Status Values -------------------------- */ 143 1.1 agc 144 1.1 agc #define ISCSI_STATUS_SUCCESS 0 /* Indicates success. */ 145 1.1 agc #define ISCSI_STATUS_LIST_EMPTY 1 /* The requested list is empty. */ 146 1.1 agc #define ISCSI_STATUS_DUPLICATE_NAME 2 /* The specified symbolic identifier is not unique. */ 147 1.1 agc #define ISCSI_STATUS_GENERAL_ERROR 3 /* A non-specific error occurred. */ 148 1.1 agc #define ISCSI_STATUS_LOGIN_FAILED 4 /* The login failed. */ 149 1.1 agc #define ISCSI_STATUS_CONNECTION_FAILED 5 /* The attempt to establish a connection failed. */ 150 1.1 agc #define ISCSI_STATUS_AUTHENTICATION_FAILED 6 /* Authentication negotiation failed. */ 151 1.1 agc #define ISCSI_STATUS_NO_RESOURCES 7 /* Could not allocate resources (e.g. memory). */ 152 1.1 agc #define ISCSI_STATUS_MAXED_CONNECTIONS 8 /* Maximum number of connections exceeded. */ 153 1.1 agc #define ISCSI_STATUS_INVALID_SESSION_ID 9 /* Session ID not found */ 154 1.1 agc #define ISCSI_STATUS_INVALID_CONNECTION_ID 10 /* Connection ID not found */ 155 1.1 agc #define ISCSI_STATUS_INVALID_SOCKET 11 /* Specified socket is invalid */ 156 1.1 agc #define ISCSI_STATUS_NOTIMPL 12 /* Feature not implemented */ 157 1.1 agc #define ISCSI_STATUS_CHECK_CONDITION 13 /* Target reported CHECK CONDITION */ 158 1.1 agc #define ISCSI_STATUS_TARGET_BUSY 14 /* Target reported BUSY */ 159 1.1 agc #define ISCSI_STATUS_TARGET_ERROR 15 /* Target reported other error */ 160 1.1 agc #define ISCSI_STATUS_TARGET_FAILURE 16 /* Command Response was Target Failure */ 161 1.1 agc #define ISCSI_STATUS_TARGET_DROP 17 /* Target dropped connection */ 162 1.1 agc #define ISCSI_STATUS_SOCKET_ERROR 18 /* Communication failure */ 163 1.1 agc #define ISCSI_STATUS_PARAMETER_MISSING 19 /* A required ioctl parameter is missing */ 164 1.1 agc #define ISCSI_STATUS_PARAMETER_INVALID 20 /* A parameter is malformed (string too long etc.) */ 165 1.1 agc #define ISCSI_STATUS_MAP_FAILED 21 /* Mapping the LUNs failed */ 166 1.1 agc #define ISCSI_STATUS_NO_INITIATOR_NAME 22 /* Initiator name was not set */ 167 1.1 agc #define ISCSI_STATUS_NEGOTIATION_ERROR 23 /* Negotiation failure (invalid key or value) */ 168 1.1 agc #define ISCSI_STATUS_TIMEOUT 24 /* Command timed out (at iSCSI level) */ 169 1.1 agc #define ISCSI_STATUS_PROTOCOL_ERROR 25 /* Internal Error (Protocol error reject) */ 170 1.1 agc #define ISCSI_STATUS_PDU_ERROR 26 /* Internal Error (Invalid PDU field reject) */ 171 1.1 agc #define ISCSI_STATUS_CMD_NOT_SUPPORTED 27 /* Target does not support iSCSI command */ 172 1.1 agc #define ISCSI_STATUS_DRIVER_UNLOAD 28 /* Driver is unloading */ 173 1.1 agc #define ISCSI_STATUS_LOGOUT 29 /* Session was logged out */ 174 1.1 agc #define ISCSI_STATUS_PDUS_LOST 30 /* Excessive PDU loss */ 175 1.1 agc #define ISCSI_STATUS_INVALID_EVENT_ID 31 /* Invalid Event ID */ 176 1.1 agc #define ISCSI_STATUS_EVENT_DEREGISTERED 32 /* Wait for event cancelled by deregistration */ 177 1.1 agc #define ISCSI_STATUS_EVENT_WAITING 33 /* Someone is already waiting for this event */ 178 1.1 agc #define ISCSI_STATUS_TASK_NOT_FOUND 34 /* Task Management: task not found */ 179 1.1 agc #define ISCSI_STATUS_LUN_NOT_FOUND 35 /* Task Management: LUN not found */ 180 1.1 agc #define ISCSI_STATUS_TASK_ALLEGIANT 36 /* Task Management: Task still allegiant */ 181 1.1 agc #define ISCSI_STATUS_CANT_REASSIGN 37 /* Task Management: Task reassignment not supported */ 182 1.1 agc #define ISCSI_STATUS_FUNCTION_UNSUPPORTED 38 /* Task Management: Function unsupported */ 183 1.1 agc #define ISCSI_STATUS_FUNCTION_NOT_AUTHORIZED 39 /* Task Management: Function not authorized */ 184 1.1 agc #define ISCSI_STATUS_FUNCTION_REJECTED 40 /* Task Management: Function rejected */ 185 1.1 agc #define ISCSI_STATUS_UNKNOWN_REASON 41 /* Task Management: Unknown reason code */ 186 1.1 agc #define ISCSI_STATUS_DUPLICATE_ID 42 /* Given ID is a duplicate */ 187 1.1 agc #define ISCSI_STATUS_INVALID_ID 43 /* Given ID was not found */ 188 1.1 agc #define ISCSI_STATUS_TARGET_LOGOUT 44 /* Target requested logout */ 189 1.1 agc #define ISCSI_STATUS_LOGOUT_CID_NOT_FOUND 45 /* Logout error: CID not found */ 190 1.1 agc #define ISCSI_STATUS_LOGOUT_RECOVERY_NS 46 /* Logout error: Recovery not supported */ 191 1.1 agc #define ISCSI_STATUS_LOGOUT_ERROR 47 /* Logout error: Unknown reason */ 192 1.4 mlelstv #define ISCSI_STATUS_QUEUE_FULL 48 /* iSCSI send window exhausted */ 193 1.1 agc 194 1.1 agc #define ISCSID_STATUS_SUCCESS 0 /* Indicates success. */ 195 1.1 agc #define ISCSID_STATUS_LIST_EMPTY 1001 /* The requested list is empty. */ 196 1.1 agc #define ISCSID_STATUS_DUPLICATE_NAME 1002 /* The specified name is not unique. */ 197 1.1 agc #define ISCSID_STATUS_GENERAL_ERROR 1003 /* A non-specific error occurred. */ 198 1.1 agc #define ISCSID_STATUS_CONNECT_ERROR 1005 /* Failed to connect to target */ 199 1.1 agc #define ISCSID_STATUS_NO_RESOURCES 1007 /* Could not allocate resources (e.g. memory). */ 200 1.1 agc #define ISCSID_STATUS_INVALID_SESSION_ID 1009 /* Session ID not found */ 201 1.1 agc #define ISCSID_STATUS_INVALID_CONNECTION_ID 1010 /* Connection ID not found */ 202 1.1 agc #define ISCSID_STATUS_NOTIMPL 1012 /* Feature not implemented */ 203 1.1 agc #define ISCSID_STATUS_SOCKET_ERROR 1018 /* Failed to create socket */ 204 1.1 agc #define ISCSID_STATUS_PARAMETER_MISSING 1019 /* A required parameter is missing */ 205 1.1 agc #define ISCSID_STATUS_PARAMETER_INVALID 1020 /* A parameter is malformed (string too long etc.) */ 206 1.1 agc #define ISCSID_STATUS_INVALID_PARAMETER 1020 /* Alternate spelling of above */ 207 1.1 agc #define ISCSID_STATUS_NO_INITIATOR_NAME 1022 /* Initiator name was not set */ 208 1.1 agc #define ISCSID_STATUS_TIMEOUT 1024 /* Request timed out */ 209 1.1 agc #define ISCSID_STATUS_DRIVER_NOT_LOADED 1028 /* Driver not loaded */ 210 1.1 agc #define ISCSID_STATUS_INVALID_REQUEST 1101 /* Unknown request code */ 211 1.1 agc #define ISCSID_STATUS_INVALID_PORTAL_ID 1102 /* Portal ID not found */ 212 1.1 agc #define ISCSID_STATUS_INVALID_TARGET_ID 1103 /* Target ID not found */ 213 1.1 agc #define ISCSID_STATUS_NOT_FOUND 1104 /* Search failed */ 214 1.1 agc #define ISCSID_STATUS_HOST_NOT_FOUND 1105 /* Target address not found */ 215 1.1 agc #define ISCSID_STATUS_HOST_TRY_AGAIN 1106 /* Target address retreival failed, try again later */ 216 1.1 agc #define ISCSID_STATUS_HOST_ERROR 1107 /* Target address invalid */ 217 1.1 agc #define ISCSID_STATUS_NO_TARGETS_FOUND 1108 /* No targets found during refresh */ 218 1.1 agc #define ISCSID_STATUS_INVALID_ISNS_ID 1111 /* iSNS ID not found */ 219 1.1 agc #define ISCSID_STATUS_ISNS_ERROR 1112 /* Problem connecting to iSNS */ 220 1.1 agc #define ISCSID_STATUS_ISNS_SERVER_ERROR 1113 /* iSNS server returned garbage */ 221 1.1 agc #define ISCSID_STATUS_DUPLICATE_ENTRY 1114 /* The specified entry already exists */ 222 1.1 agc #define ISCSID_STATUS_INVALID_INITIATOR_ID 1115 /* Initiator ID not found */ 223 1.1 agc #define ISCSID_STATUS_INITIATOR_BIND_ERROR 1116 /* Bind to initiator portal failed */ 224 1.1 agc 225 1.1 agc #endif /* !_ISCSI_H */ 226