2 * Copyright (c) 2012 The FreeBSD Foundation
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifdef ICL_KERNEL_PROXY
36 #include <sys/socket.h>
39 #define ISCSI_PATH "/dev/iscsi"
40 #define ISCSI_MAX_DATA_SEGMENT_LENGTH (128 * 1024)
42 #define ISCSI_NAME_LEN 224 /* 223 bytes, by RFC 3720, + '\0' */
43 #define ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */
44 #define ISCSI_ALIAS_LEN 256 /* XXX: Where did it come from? */
45 #define ISCSI_SECRET_LEN 17 /* 16 + '\0' */
46 #define ISCSI_OFFLOAD_LEN 8
47 #define ISCSI_REASON_LEN 64
49 #define ISCSI_DIGEST_NONE 0
50 #define ISCSI_DIGEST_CRC32C 1
53 * Session configuration, set when adding the session.
55 struct iscsi_session_conf {
56 char isc_initiator[ISCSI_NAME_LEN];
57 char isc_initiator_addr[ISCSI_ADDR_LEN];
58 char isc_initiator_alias[ISCSI_ALIAS_LEN];
59 char isc_target[ISCSI_NAME_LEN];
60 char isc_target_addr[ISCSI_ADDR_LEN];
61 char isc_user[ISCSI_NAME_LEN];
62 char isc_secret[ISCSI_SECRET_LEN];
63 char isc_mutual_user[ISCSI_NAME_LEN];
64 char isc_mutual_secret[ISCSI_SECRET_LEN];
66 int isc_header_digest;
69 char isc_offload[ISCSI_OFFLOAD_LEN];
74 * Additional constraints imposed by chosen ICL offload module;
75 * iscsid(8) must obey those when negotiating operational parameters.
77 struct iscsi_session_limits {
78 size_t isl_max_data_segment_length;
82 * Session state, negotiated by iscsid(8) and queried by iscsictl(8).
84 struct iscsi_session_state {
85 struct iscsi_session_conf iss_conf;
87 char iss_target_alias[ISCSI_ALIAS_LEN];
88 int iss_header_digest;
90 int iss_max_data_segment_length;
91 int iss_immediate_data;
93 char iss_reason[ISCSI_REASON_LEN];
94 char iss_offload[ISCSI_OFFLOAD_LEN];
99 * The following ioctls are used by iscsid(8).
101 struct iscsi_daemon_request {
102 unsigned int idr_session_id;
103 struct iscsi_session_conf idr_conf;
106 uint16_t idr_spare_cid;
107 struct iscsi_session_limits idr_limits;
111 struct iscsi_daemon_handoff {
112 unsigned int idh_session_id;
114 char idh_target_alias[ISCSI_ALIAS_LEN];
115 uint8_t idh_spare_isid[6];
117 uint16_t idh_spare_cid;
119 int idh_header_digest;
122 int idh_immediate_data;
123 size_t idh_max_data_segment_length;
124 size_t idh_max_burst_length;
125 size_t idh_first_burst_length;
129 struct iscsi_daemon_fail {
130 unsigned int idf_session_id;
131 char idf_reason[ISCSI_REASON_LEN];
135 #define ISCSIDWAIT _IOR('I', 0x01, struct iscsi_daemon_request)
136 #define ISCSIDHANDOFF _IOW('I', 0x02, struct iscsi_daemon_handoff)
137 #define ISCSIDFAIL _IOW('I', 0x03, struct iscsi_daemon_fail)
139 #ifdef ICL_KERNEL_PROXY
142 * When ICL_KERNEL_PROXY is not defined, the iscsid(8) is responsible
143 * for creating the socket, connecting, and performing Login Phase using
144 * the socket in the usual userspace way, and then passing the socket
145 * file descriptor to the kernel part using ISCSIDHANDOFF.
147 * When ICL_KERNEL_PROXY is defined, the iscsid(8) creates the session
148 * using ISCSICONNECT, performs Login Phase using ISCSISEND/ISCSIRECEIVE
149 * instead of read(2)/write(2), and then calls ISCSIDHANDOFF with
150 * idh_socket set to 0.
152 * The purpose of ICL_KERNEL_PROXY is to workaround the fact that,
153 * at this time, it's not possible to do iWARP (RDMA) in userspace.
156 struct iscsi_daemon_connect {
162 struct sockaddr *idc_from_addr;
163 socklen_t idc_from_addrlen;
164 struct sockaddr *idc_to_addr;
165 socklen_t idc_to_addrlen;
169 struct iscsi_daemon_send {
174 size_t ids_data_segment_len;
175 void *ids_data_segment;
179 struct iscsi_daemon_receive {
184 size_t idr_data_segment_len;
185 void *idr_data_segment;
189 #define ISCSIDCONNECT _IOWR('I', 0x04, struct iscsi_daemon_connect)
190 #define ISCSIDSEND _IOWR('I', 0x05, struct iscsi_daemon_send)
191 #define ISCSIDRECEIVE _IOWR('I', 0x06, struct iscsi_daemon_receive)
193 #endif /* ICL_KERNEL_PROXY */
196 * The following ioctls are used by iscsictl(8).
198 struct iscsi_session_add {
199 struct iscsi_session_conf isa_conf;
203 struct iscsi_session_remove {
204 unsigned int isr_session_id;
205 struct iscsi_session_conf isr_conf;
209 struct iscsi_session_list {
210 unsigned int isl_nentries;
211 struct iscsi_session_state *isl_pstates;
215 struct iscsi_session_modify {
216 unsigned int ism_session_id;
217 struct iscsi_session_conf ism_conf;
221 #define ISCSISADD _IOW('I', 0x11, struct iscsi_session_add)
222 #define ISCSISREMOVE _IOW('I', 0x12, struct iscsi_session_remove)
223 #define ISCSISLIST _IOWR('I', 0x13, struct iscsi_session_list)
224 #define ISCSISMODIFY _IOWR('I', 0x14, struct iscsi_session_modify)
226 #endif /* !ISCSI_IOCTL_H */