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